work in progress on graphics
authorMichael Welch <michaelgwelch@gmail.com>
Sun, 11 Feb 2007 03:21:00 +0000 (03:21 +0000)
committerMichael Welch <michaelgwelch@gmail.com>
Sun, 11 Feb 2007 03:21:00 +0000 (03:21 +0000)
WindowsApplication1/Form1.cs
WindowsApplication1/Screen.Designer.cs [deleted file]
WindowsApplication1/Screen.cs
WindowsApplication1/Screen.resx [deleted file]

index eb4facb..afbb82b 100644 (file)
@@ -255,8 +255,8 @@ namespace WindowsApplication1
             screen1.Print("Hello, World!");
             screen1.Print("I'm a TI Basic Look alike");
 
-            screen1.Char((char)128, "1898FF3D3C3CE404");
-            screen1.Char((char)129, "1819FFBC3C3C2720");
+            screen1.CharacterDefinition((char)128, "1898FF3D3C3CE404");
+            screen1.CharacterDefinition((char)129, "1819FFBC3C3C2720");
             timer.Interval = 500;
             screen1.Color(13, TIColor.DarkRed, TIColor.White);
             timer.Tick += timer_Tick;
@@ -268,8 +268,8 @@ namespace WindowsApplication1
         bool image1 = false;
         void timer_Tick(object sender, EventArgs e)
         {
-            if (image1) screen1.VChar(12, 16, (char)128);
-            else screen1.VChar(12, 16, (char)129);
+            if (image1) screen1.VerticalCharacterRepeat(12, 16, (char)128);
+            else screen1.VerticalCharacterRepeat(12, 16, (char)129);
             image1 = !image1;
 
 
diff --git a/WindowsApplication1/Screen.Designer.cs b/WindowsApplication1/Screen.Designer.cs
deleted file mode 100644 (file)
index f58a74e..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-namespace WindowsApplication1
-{
-    partial class Screen
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.button1 = new System.Windows.Forms.Button();
-            this.SuspendLayout();
-            // 
-            // button1
-            // 
-            this.button1.Location = new System.Drawing.Point(101, 62);
-            this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(75, 23);
-            this.button1.TabIndex = 0;
-            this.button1.Text = "button1";
-            this.button1.UseVisualStyleBackColor = true;
-            this.button1.Click += new System.EventHandler(this.button1_Click_1);
-            // 
-            // Form1
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(204)))), ((int)(((byte)(255)))));
-            this.ClientSize = new System.Drawing.Size(292, 256);
-            this.Controls.Add(this.button1);
-            this.Name = "Form1";
-            this.Text = "Form1";
-            this.Load += new System.EventHandler(this.Form1_Load);
-            this.ResumeLayout(false);
-
-        }
-
-        #endregion
-
-        private System.Windows.Forms.Button button1;
-
-    }
-}
-
index 6efbcbe..bf5dfdd 100644 (file)
@@ -1,3 +1,25 @@
+/*******************************************************************************
+    Copyright 2007 Michael Welch
+    
+    This file is part of MBasic99.
+
+    MBasic99 is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    MBasic99 is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with MBasic99; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*******************************************************************************/
+
+
+
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -14,40 +36,45 @@ namespace WindowsApplication1
         private const int numCols = 32;
         private const int numRows = 24;
         private const int firstPrintCol = 2;
+        private const char space = ' ';
+        private const int pixelsPerCell = 8;
 
         // circular buffer.
         private CharacterBitmap characters;
-        private Bitmap[][] cells;
+        private char[][] cells;
         private int bottomRow;
 
         public Screen()
         {
             characters = new CharacterBitmap();
-            Height = 24 * 8 * yScaleFactor; // 24 rows * 8 pixels/row * scaling factor of 2
-            Width = 32 * 8 * xScaleFactor;  // 32 cols * 8 pixels/col * scaling factor of 2
+            Height = numRows * pixelsPerCell * yScaleFactor; // 24 rows * 8 pixels/row * scaling factor of 2
+            Width = numCols * pixelsPerCell * xScaleFactor;  // 32 cols * 8 pixels/col * scaling factor of 2
             SetStyle(ControlStyles.UserPaint |
                   ControlStyles.OptimizedDoubleBuffer |
                   ControlStyles.AllPaintingInWmPaint, true);
             BackColor = TIColor.Cyan;
 
             // cells is an array of 24 rows.
-            // each element is an array of bitmaps.
-            cells = new Bitmap[numRows][];
+            // each element is an array of chars.
+            cells = new char[numRows][];
 
             for (int row = 0; row < numRows; row++)
             {
-                cells[row] = new Bitmap[numCols];
-                for (int col = 0; col < numCols; col++)
-                {
-                    cells[row][col] = characters.Space;
-                }
+                cells[row] = new char[numCols];
             }
+            Clear();
+        }
 
+        public void Clear()
+        {
+            for (int row = 0; row < numRows; row++)
+                for (int col = 0; col < numCols; col++)
+                    cells[row][col] = space;
         }
 
+
         public void Color(int characterSet, TIColor foreColor, TIColor backColor)
         {
-
             characters.Color(characterSet, foreColor, backColor);
             Invalidate();
         }
@@ -67,7 +94,6 @@ namespace WindowsApplication1
         protected override void OnPaint(PaintEventArgs pe)
         {
             base.OnPaint(pe);
-            Rectangle badArea = pe.ClipRectangle;
             Graphics g = pe.Graphics;
 
             g.Clear(BackColor);
@@ -80,8 +106,7 @@ namespace WindowsApplication1
                 int displayRow = CalculateDisplayRow(row);
                 for (int col = 0; col < numCols; col++)
                 {
-                    Bitmap bm = cells[row][col];
-                    if (bm == null) continue;
+                    Bitmap bm = characters[cells[row][col]];
                     g.DrawImage(bm, CalculateDisplayPosition(displayRow, col));
                 }
             }
@@ -103,14 +128,14 @@ namespace WindowsApplication1
             for (int i = 0; i < value.Length; i++)
             {
                 char ch = value[i];
-                cells[bottomRow][i+firstPrintCol] = characters[ch];
+                cells[bottomRow][i + firstPrintCol] = ch;
             }
             Invalidate();
         }
 
-        public void HChar(int rowNum, int colNum, char ch)
+        public void HorizontalCharacterRepeat(int rowNum, int colNum, char ch)
         {
-            HChar(rowNum, colNum, ch, 1);
+            HorizontalCharacterRepeat(rowNum, colNum, ch, 1);
         }
 
         /// <summary>
@@ -120,7 +145,7 @@ namespace WindowsApplication1
         /// <param name="colNum"></param>
         /// <param name="ch"></param>
         /// <param name="repeat"></param>
-        public void HChar(int rowNum, int colNum, char ch, int repeat)
+        public void HorizontalCharacterRepeat(int rowNum, int colNum, char ch, int repeat)
         {
             for (int i = 0; i < repeat; i++)
             {
@@ -130,17 +155,17 @@ namespace WindowsApplication1
                     colNum = 0;
                     rowNum = (rowNum + 1) % numRows;
                 }
-                cells[rowNum][colNum] = characters[ch];
+                cells[rowNum][colNum] = ch;
             }
             Invalidate();
         }
 
-        public void VChar(int rowNum, int colNum, char ch)
+        public void VerticalCharacterRepeat(int rowNum, int colNum, char ch)
         {
-            VChar(rowNum, colNum, ch, 1);
+            VerticalCharacterRepeat(rowNum, colNum, ch, 1);
         }
 
-        public void VChar(int rowNum, int colNum, char ch, int repeat)
+        public void VerticalCharacterRepeat(int rowNum, int colNum, char ch, int repeat)
         {
             for (int i = 0; i < repeat; i++)
             {
@@ -150,12 +175,17 @@ namespace WindowsApplication1
                     rowNum = 0;
                     colNum = (colNum + 1) % numCols;
                 }
-                cells[rowNum][colNum] = characters[ch];
+                cells[rowNum][colNum] = ch;
             }
             Invalidate();
         }
 
-        public void Char(char ch, string hexCodes)
+        public char GetCharacter(int rowNum, int colNum)
+        {
+            return cells[rowNum][colNum];
+        }
+
+        public void CharacterDefinition(char ch, string hexCodes)
         {
             characters.ModifyBitmap(ch, hexCodes);
         }
@@ -165,7 +195,7 @@ namespace WindowsApplication1
             bottomRow = (bottomRow+1) % 24;
             for (int col = 0; col < numCols; col++)
             {
-                cells[bottomRow][col] = characters.Space;
+                cells[bottomRow][col] = space;
             }
         }
     }
diff --git a/WindowsApplication1/Screen.resx b/WindowsApplication1/Screen.resx
deleted file mode 100644 (file)
index ff31a6d..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<root>\r
-  <!-- \r
-    Microsoft ResX Schema \r
-    \r
-    Version 2.0\r
-    \r
-    The primary goals of this format is to allow a simple XML format \r
-    that is mostly human readable. The generation and parsing of the \r
-    various data types are done through the TypeConverter classes \r
-    associated with the data types.\r
-    \r
-    Example:\r
-    \r
-    ... ado.net/XML headers & schema ...\r
-    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
-    <resheader name="version">2.0</resheader>\r
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
-        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
-    </data>\r
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
-        <comment>This is a comment</comment>\r
-    </data>\r
-                \r
-    There are any number of "resheader" rows that contain simple \r
-    name/value pairs.\r
-    \r
-    Each data row contains a name, and value. The row also contains a \r
-    type or mimetype. Type corresponds to a .NET class that support \r
-    text/value conversion through the TypeConverter architecture. \r
-    Classes that don't support this are serialized and stored with the \r
-    mimetype set.\r
-    \r
-    The mimetype is used for serialized objects, and tells the \r
-    ResXResourceReader how to depersist the object. This is currently not \r
-    extensible. For a given mimetype the value must be set accordingly:\r
-    \r
-    Note - application/x-microsoft.net.object.binary.base64 is the format \r
-    that the ResXResourceWriter will generate, however the reader can \r
-    read any of the formats listed below.\r
-    \r
-    mimetype: application/x-microsoft.net.object.binary.base64\r
-    value   : The object must be serialized with \r
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
-            : and then encoded with base64 encoding.\r
-    \r
-    mimetype: application/x-microsoft.net.object.soap.base64\r
-    value   : The object must be serialized with \r
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
-            : and then encoded with base64 encoding.\r
-\r
-    mimetype: application/x-microsoft.net.object.bytearray.base64\r
-    value   : The object must be serialized into a byte array \r
-            : using a System.ComponentModel.TypeConverter\r
-            : and then encoded with base64 encoding.\r
-    -->\r
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
-    <xsd:element name="root" msdata:IsDataSet="true">\r
-      <xsd:complexType>\r
-        <xsd:choice maxOccurs="unbounded">\r
-          <xsd:element name="metadata">\r
-            <xsd:complexType>\r
-              <xsd:sequence>\r
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
-              </xsd:sequence>\r
-              <xsd:attribute name="name" use="required" type="xsd:string" />\r
-              <xsd:attribute name="type" type="xsd:string" />\r
-              <xsd:attribute name="mimetype" type="xsd:string" />\r
-              <xsd:attribute ref="xml:space" />\r
-            </xsd:complexType>\r
-          </xsd:element>\r
-          <xsd:element name="assembly">\r
-            <xsd:complexType>\r
-              <xsd:attribute name="alias" type="xsd:string" />\r
-              <xsd:attribute name="name" type="xsd:string" />\r
-            </xsd:complexType>\r
-          </xsd:element>\r
-          <xsd:element name="data">\r
-            <xsd:complexType>\r
-              <xsd:sequence>\r
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
-              </xsd:sequence>\r
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
-              <xsd:attribute ref="xml:space" />\r
-            </xsd:complexType>\r
-          </xsd:element>\r
-          <xsd:element name="resheader">\r
-            <xsd:complexType>\r
-              <xsd:sequence>\r
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
-              </xsd:sequence>\r
-              <xsd:attribute name="name" type="xsd:string" use="required" />\r
-            </xsd:complexType>\r
-          </xsd:element>\r
-        </xsd:choice>\r
-      </xsd:complexType>\r
-    </xsd:element>\r
-  </xsd:schema>\r
-  <resheader name="resmimetype">\r
-    <value>text/microsoft-resx</value>\r
-  </resheader>\r
-  <resheader name="version">\r
-    <value>2.0</value>\r
-  </resheader>\r
-  <resheader name="reader">\r
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
-  </resheader>\r
-  <resheader name="writer">\r
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
-  </resheader>\r
-</root>
\ No newline at end of file