summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-01-21 01:13:58 +0000
committerIan C <ianc@noddybox.co.uk>2005-01-21 01:13:58 +0000
commitf0a9af7158f2faf6359beef5602451b6a042a539 (patch)
treef9c0b00d2067777d9c7d8548f0d7b00a76a85e6d
parent88256e4aed5262e7c50f351264d5f163ffe8e7ef (diff)
Initial checkin
-rw-r--r--About.cs158
-rw-r--r--AssemblyInfo.cs33
-rw-r--r--CompileScript.cs105
-rw-r--r--DebugForm.cs109
-rw-r--r--ExecuteForm.cs152
-rw-r--r--Help.resourcesbin0 -> 1763 bytes
-rw-r--r--MainForm.cs304
-rw-r--r--SID.cs140
-rw-r--r--SIDFX.About.resourcesbin0 -> 6337 bytes
-rw-r--r--SIDFX.DebugForm.resourcesbin0 -> 2979 bytes
-rw-r--r--SIDFX.ExecuteForm.resourcesbin0 -> 4761 bytes
-rw-r--r--SIDFX.MainForm.resourcesbin0 -> 4183 bytes
-rw-r--r--SIDFX.PlayForm.resourcesbin0 -> 27069 bytes
-rw-r--r--SIDFX.cmbx24
-rw-r--r--SIDFX.prjx40
-rw-r--r--Util.cs52
-rw-r--r--help.rtfbin0 -> 1429 bytes
17 files changed, 1117 insertions, 0 deletions
diff --git a/About.cs b/About.cs
new file mode 100644
index 0000000..2bd728d
--- /dev/null
+++ b/About.cs
@@ -0,0 +1,158 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Windows.Forms;
+using System.Text;
+using System.Resources;
+using System.Reflection;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Description of About
+ /// </summary>
+ public class About : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label m_gpl;
+ private System.Windows.Forms.RichTextBox m_help;
+ private System.Windows.Forms.Label m_title;
+ private System.Windows.Forms.Button m_ok;
+
+ public About()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ StringBuilder s=new StringBuilder();
+
+ m_title.Text="GfxEd8 (c) Copyright 2004 Ian Cowburn";
+
+ s.Append("This program is distributed in the hope that it will be useful, ");
+ s.Append("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
+ s.Append("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ");
+ s.Append("GNU General Public License for more details.");
+
+ m_gpl.Text=s.ToString();
+
+ m_title.Text="SIDFX (c) Copyright 2004 Ian Cowburn";
+
+ ResourceManager mgr=new ResourceManager("Help",
+ Assembly.GetExecutingAssembly());
+
+ byte[] rtf=(byte[])mgr.GetObject("help");
+
+ if (rtf!=null)
+ {
+ m_help.Rtf=new ASCIIEncoding().GetString(rtf);
+ }
+ else
+ {
+ m_help.Text="Failed to read help from resources";
+ }
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.m_ok = new System.Windows.Forms.Button();
+ this.m_title = new System.Windows.Forms.Label();
+ this.m_help = new System.Windows.Forms.RichTextBox();
+ this.m_gpl = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // m_ok
+ //
+ this.m_ok.Location = new System.Drawing.Point(424, 368);
+ this.m_ok.Name = "m_ok";
+ this.m_ok.Size = new System.Drawing.Size(88, 24);
+ this.m_ok.TabIndex = 2;
+ this.m_ok.Text = "OK";
+ this.m_ok.Click += new System.EventHandler(this.OnOK);
+ //
+ // m_title
+ //
+ this.m_title.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_title.Location = new System.Drawing.Point(8, 8);
+ this.m_title.Name = "m_title";
+ this.m_title.Size = new System.Drawing.Size(504, 32);
+ this.m_title.TabIndex = 7;
+ this.m_title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // m_help
+ //
+ this.m_help.BackColor = System.Drawing.SystemColors.Info;
+ this.m_help.Cursor = System.Windows.Forms.Cursors.Default;
+ this.m_help.Location = new System.Drawing.Point(8, 144);
+ this.m_help.Name = "m_help";
+ this.m_help.ReadOnly = true;
+ this.m_help.Size = new System.Drawing.Size(504, 216);
+ this.m_help.TabIndex = 9;
+ this.m_help.Text = "";
+ //
+ // m_gpl
+ //
+ this.m_gpl.Location = new System.Drawing.Point(72, 56);
+ this.m_gpl.Name = "m_gpl";
+ this.m_gpl.Size = new System.Drawing.Size(392, 56);
+ this.m_gpl.TabIndex = 0;
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(8, 128);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(120, 16);
+ this.label1.TabIndex = 8;
+ this.label1.Text = "Scripting help:";
+ //
+ // About
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(522, 399);
+ this.Controls.Add(this.m_help);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.m_title);
+ this.Controls.Add(this.m_ok);
+ this.Controls.Add(this.m_gpl);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "About";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "About SID FX";
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+
+ void OnOK(object sender, System.EventArgs e)
+ {
+ Close();
+ }
+ }
+}
diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs
new file mode 100644
index 0000000..965e66d
--- /dev/null
+++ b/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+// $Id$
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes specify the key for the sign of your assembly. See the
+// .NET Framework documentation for more information about signing.
+// This is not required, if you don't want signing let these attributes like they're.
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
diff --git a/CompileScript.cs b/CompileScript.cs
new file mode 100644
index 0000000..cbdb5b8
--- /dev/null
+++ b/CompileScript.cs
@@ -0,0 +1,105 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using Microsoft.CSharp;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Reflection;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Description of CompileScript.
+ /// </summary>
+ public class CompileScript
+ {
+ // -------------------------------------------------------
+ // PUBLIC
+ // -------------------------------------------------------
+
+ public CompileScript(string script)
+ {
+ try
+ {
+ script="using System;using SIDFX;\nusing System.Threading;\nclass Script { public void Main() {\n"+script;
+ script=script+"}}";
+
+ m_provider=new CSharpCodeProvider();
+ m_compiler=m_provider.CreateCompiler();
+ m_param=new CompilerParameters();
+
+ m_param.GenerateExecutable=false;
+ m_param.GenerateInMemory=true;
+ m_param.OutputAssembly=null;
+ m_param.MainClass="Script.Main";
+ m_param.IncludeDebugInformation=false;
+
+ foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) {
+ m_param.ReferencedAssemblies.Add(a.Location);
+ }
+
+ m_results=m_compiler.CompileAssemblyFromSource(m_param,script);
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ public bool HasErrors
+ {
+ get
+ {
+ if (m_results!=null)
+ {
+ return m_results.Errors.Count>0;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ }
+
+ public CompilerErrorCollection Errors
+ {
+ get {return m_results.Errors;}
+ }
+
+ public void Run()
+ {
+ if (!HasErrors)
+ {
+ object o = m_results.CompiledAssembly.CreateInstance("Script");
+ Type type = o.GetType();
+ MethodInfo m = type.GetMethod("Main");
+ m.Invoke(o, null);
+ }
+ }
+
+ // -------------------------------------------------------
+ // PRIVATE
+ // -------------------------------------------------------
+ private CSharpCodeProvider m_provider=null;
+ private ICodeCompiler m_compiler=null;
+ private CompilerParameters m_param=null;
+ private CompilerResults m_results=null;
+ }
+}
diff --git a/DebugForm.cs b/DebugForm.cs
new file mode 100644
index 0000000..d778ddc
--- /dev/null
+++ b/DebugForm.cs
@@ -0,0 +1,109 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using HardsidInterface;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Description of DebugForm.
+ /// </summary>
+ public class DebugForm : System.Windows.Forms.Form
+ {
+ private Label[] m_reg;
+
+ public DebugForm()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ m_reg=new Label[25];
+
+ Font fnt=new System.Drawing.Font
+ ("Courier New", 9.75F, FontStyle.Regular,
+ GraphicsUnit.Point, ((System.Byte)(0)));
+
+ for(int f=0;f<25;f++)
+ {
+ m_reg[f]=new Label();
+
+ Point p=new Point(((f%5)*60+10),
+ ((f/5)*20+10));
+
+ m_reg[f].Text=LabelText((uint)f,0);
+ m_reg[f].Location=p;
+ m_reg[f].Font=fnt;
+ m_reg[f].AutoSize=true;
+
+ Controls.Add(m_reg[f]);
+ }
+ }
+
+ public void StartDebug()
+ {
+ Hardsid.DebugWrite+=new Hardsid.DebugEvent(Write);
+ Show();
+ }
+
+ public void StopDebug()
+ {
+ Hardsid.DebugWrite-=new Hardsid.DebugEvent(Write);
+ Hide();
+ }
+
+ private void Write(uint dev, uint r, uint v)
+ {
+ m_reg[r].Text=LabelText(r,Hardsid.Read(r));
+ }
+
+ private string LabelText(uint r, uint v)
+ {
+ return (r&0xffu).ToString("X02")+"="+(v&0xffu).ToString("x02");
+ }
+
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ //
+ // DebugForm
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(394, 135);
+ this.ControlBox = false;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "DebugForm";
+ this.ShowInTaskbar = false;
+ this.Text = "SID Registers";
+ this.TopMost = true;
+ }
+ #endregion
+ }
+}
diff --git a/ExecuteForm.cs b/ExecuteForm.cs
new file mode 100644
index 0000000..d21f229
--- /dev/null
+++ b/ExecuteForm.cs
@@ -0,0 +1,152 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Windows.Forms;
+using System.Threading;
+using HardsidInterface;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Description of ExecuteForm.
+ /// </summary>
+ public class ExecuteForm : System.Windows.Forms.Form
+ {
+ private System.ComponentModel.IContainer components;
+ private System.Windows.Forms.Button m_stopButton;
+ private System.Windows.Forms.Button m_okButton;
+ private System.Windows.Forms.Timer m_timer;
+ private System.Windows.Forms.Label m_status;
+
+ private Thread m_thread;
+
+ public ExecuteForm(CompileScript script)
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ m_status.Text="Running...";
+
+ m_thread=new Thread(new ThreadStart(script.Run));
+ }
+
+ public void Run(Form parent)
+ {
+ m_timer.Enabled=true;
+ m_thread.Start();
+ ShowDialog(parent);
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.components = new System.ComponentModel.Container();
+ this.m_status = new System.Windows.Forms.Label();
+ this.m_timer = new System.Windows.Forms.Timer(this.components);
+ this.m_okButton = new System.Windows.Forms.Button();
+ this.m_stopButton = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // m_status
+ //
+ this.m_status.Location = new System.Drawing.Point(8, 8);
+ this.m_status.Name = "m_status";
+ this.m_status.Size = new System.Drawing.Size(136, 24);
+ this.m_status.TabIndex = 2;
+ this.m_status.Text = "label1";
+ //
+ // m_timer
+ //
+ this.m_timer.Tick += new System.EventHandler(this.OnTimer);
+ //
+ // m_okButton
+ //
+ this.m_okButton.Enabled = false;
+ this.m_okButton.Location = new System.Drawing.Point(112, 40);
+ this.m_okButton.Name = "m_okButton";
+ this.m_okButton.Size = new System.Drawing.Size(88, 24);
+ this.m_okButton.TabIndex = 1;
+ this.m_okButton.Text = "OK";
+ this.m_okButton.Click += new System.EventHandler(this.OnOK);
+ //
+ // m_stopButton
+ //
+ this.m_stopButton.Location = new System.Drawing.Point(8, 40);
+ this.m_stopButton.Name = "m_stopButton";
+ this.m_stopButton.Size = new System.Drawing.Size(88, 24);
+ this.m_stopButton.TabIndex = 0;
+ this.m_stopButton.Text = "Stop!";
+ this.m_stopButton.Click += new System.EventHandler(this.OnStop);
+ //
+ // ExecuteForm
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
+ this.ClientSize = new System.Drawing.Size(210, 71);
+ this.ControlBox = false;
+ this.Controls.Add(this.m_status);
+ this.Controls.Add(this.m_okButton);
+ this.Controls.Add(this.m_stopButton);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "ExecuteForm";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Script";
+ this.ResumeLayout(false);
+ }
+ #endregion
+ void OnTimer(object sender, System.EventArgs e)
+ {
+ if (!m_thread.IsAlive)
+ {
+ m_stopButton.Enabled=false;
+ m_okButton.Enabled=true;
+ m_timer.Enabled=false;
+ m_status.Text="Stopped";
+ }
+ }
+
+ void OnOK(object sender, System.EventArgs e)
+ {
+ for(uint r=0;r<25;r++)
+ {
+ Hardsid.Write(r,0);
+ }
+
+ Close();
+ }
+
+ void OnStop(object sender, System.EventArgs e)
+ {
+ if (m_thread.IsAlive)
+ {
+ m_thread.Abort();
+ OnTimer(null,null);
+ }
+ }
+ }
+}
diff --git a/Help.resources b/Help.resources
new file mode 100644
index 0000000..c3cb964
--- /dev/null
+++ b/Help.resources
Binary files differ
diff --git a/MainForm.cs b/MainForm.cs
new file mode 100644
index 0000000..d062e91
--- /dev/null
+++ b/MainForm.cs
@@ -0,0 +1,304 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Windows.Forms;
+using System.IO;
+using System.Text;
+using System.CodeDom.Compiler;
+using Noddybox.GUI;
+using HardsidInterface;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Description of MainForm.
+ /// </summary>
+ public class MainForm : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.RichTextBox m_edit;
+ private System.Windows.Forms.Button m_runButton;
+ private System.Windows.Forms.CheckBox m_showDebug;
+
+ private MainMenu m_mainMenu;
+ private MenuTree m_menu;
+ private string m_path;
+ private bool m_changed;
+ private DebugForm m_debug;
+
+ public MainForm()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ m_debug=new DebugForm();
+
+ m_mainMenu=new MainMenu();
+ m_menu=new MenuTree(m_mainMenu);
+
+ m_menu.Add("/file", "File");
+ m_menu.Add("/file/new", "New", new EventHandler(OnNew));
+ m_menu.Add("/file/open", "Open...", new EventHandler(OnOpen));
+ m_menu.Add("/file/save", "Save", new EventHandler(OnSave));
+ m_menu.Add("/file/saveas", "Save as...", new EventHandler(OnSaveAs));
+ m_menu.Add("/file/quit", "Quit", new EventHandler(OnQuit));
+
+ m_menu.Add("/sid","SID");
+ m_menu.Add("/sid/run","Run Script", new EventHandler(OnRun));
+
+ m_menu.Add("/help","Help");
+ m_menu.Add("/help/about","About...", new EventHandler(OnAbout));
+
+ m_menu.Get("/file/save").Enabled=false;
+
+ m_path="";
+ m_changed=false;
+
+ Menu=m_mainMenu;
+
+ //Hardsid.Init();
+ Hardsid.DLLDebug(1);
+ }
+
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ Application.Run(new MainForm());
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.m_showDebug = new System.Windows.Forms.CheckBox();
+ this.m_runButton = new System.Windows.Forms.Button();
+ this.m_edit = new System.Windows.Forms.RichTextBox();
+ this.SuspendLayout();
+ //
+ // m_showDebug
+ //
+ this.m_showDebug.Location = new System.Drawing.Point(8, 368);
+ this.m_showDebug.Name = "m_showDebug";
+ this.m_showDebug.Size = new System.Drawing.Size(184, 16);
+ this.m_showDebug.TabIndex = 2;
+ this.m_showDebug.Text = "Show SID Register Window";
+ this.m_showDebug.CheckedChanged += new System.EventHandler(this.OnShowDebug);
+ //
+ // m_runButton
+ //
+ this.m_runButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.m_runButton.Location = new System.Drawing.Point(512, 368);
+ this.m_runButton.Name = "m_runButton";
+ this.m_runButton.Size = new System.Drawing.Size(80, 24);
+ this.m_runButton.TabIndex = 1;
+ this.m_runButton.Text = "Run";
+ this.m_runButton.Click += new System.EventHandler(this.OnRun);
+ //
+ // m_edit
+ //
+ this.m_edit.AcceptsTab = true;
+ this.m_edit.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.m_edit.DetectUrls = false;
+ this.m_edit.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.m_edit.Location = new System.Drawing.Point(8, 0);
+ this.m_edit.Name = "m_edit";
+ this.m_edit.Size = new System.Drawing.Size(584, 360);
+ this.m_edit.TabIndex = 0;
+ this.m_edit.Text = "";
+ this.m_edit.WordWrap = false;
+ this.m_edit.TextChanged += new System.EventHandler(this.OnTextChanged);
+ this.m_edit.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnKeyUp);
+ //
+ // MainForm
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(600, 397);
+ this.Controls.Add(this.m_showDebug);
+ this.Controls.Add(this.m_runButton);
+ this.Controls.Add(this.m_edit);
+ this.Name = "MainForm";
+ this.Text = "SID FX - Untitled";
+ this.Closing += new System.ComponentModel.CancelEventHandler(this.OnFormClosing);
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+ void OnNew(object sender, System.EventArgs e)
+ {
+ m_menu.Get("/file/save").Enabled=false;
+ m_path="";
+ m_edit.Text="";
+ m_changed=false;
+ Text="SID FX - Untitled";
+ }
+
+ void OnOpen(object sender, System.EventArgs e)
+ {
+ if (!m_changed || Util.YesNo("Lose current edits?"))
+ {
+ OpenFileDialog fsel=new OpenFileDialog();
+
+ fsel.FileName=m_path;
+ fsel.Filter="SIDFX files (*.sdx)|*.sdx|All files (*.*)|*.*";
+ fsel.FilterIndex=1;
+
+ if(fsel.ShowDialog()==DialogResult.OK)
+ {
+ m_path=fsel.FileName;
+
+ try
+ {
+ m_edit.LoadFile(m_path,RichTextBoxStreamType.PlainText);
+ m_menu.Get("/file/save").Enabled=true;
+ m_changed=false;
+ Text="SID FX - " + m_path;
+ }
+ catch
+ {
+ Util.Error("Error reading " + m_path);
+ }
+ }
+ }
+ }
+
+ void OnSave(object sender, System.EventArgs e)
+ {
+ try
+ {
+ m_edit.SaveFile(m_path,RichTextBoxStreamType.PlainText);
+ m_changed=false;
+ }
+ catch
+ {
+ Util.Error("Error writing " + m_path);
+ }
+ }
+
+ void OnSaveAs(object sender, System.EventArgs e)
+ {
+ SaveFileDialog fsel=new SaveFileDialog();
+
+ fsel.FileName=m_path;
+ fsel.Filter="SIDFX files (*.sdx)|*.sdx|All files (*.*)|*.*";
+ fsel.FilterIndex=1;
+
+ if(fsel.ShowDialog()==DialogResult.OK)
+ {
+ m_path=fsel.FileName;
+
+ OnSave(sender,e);
+ m_menu.Get("/file/save").Enabled=true;
+ m_changed=false;
+ Text="SID FX - " + m_path;
+ }
+ }
+
+ void OnQuit(object sender, System.EventArgs e)
+ {
+ if (!m_changed || Util.YesNo("Lose current edits?"))
+ {
+ // This prevents OnFormClosing() asking again
+ //
+ m_changed=false;
+
+ Close();
+ }
+ }
+
+ void OnAbout(object sender, System.EventArgs e)
+ {
+ Form about=new About();
+
+ about.ShowDialog(this);
+ }
+
+ void OnRun(object sender, System.EventArgs e)
+ {
+ if (Hardsid.Count<1)
+ {
+ Util.Error("This machine has no HardSIDs!");
+ return;
+ }
+
+ CompileScript comp=new CompileScript(m_edit.Text);
+
+ if (comp.HasErrors)
+ {
+ StringBuilder s=new StringBuilder();
+
+ s.Append("Errors compiling the script:\n");
+
+ foreach (CompilerError err in comp.Errors)
+ {
+ s.Append(err.ToString()+"\n");
+ }
+
+ Util.Error(s.ToString());
+ }
+ else
+ {
+ ExecuteForm exec=new ExecuteForm(comp);
+
+ exec.Run(this);
+ }
+ }
+
+ void OnTextChanged(object sender, System.EventArgs e)
+ {
+ m_changed=true;
+ }
+
+ void OnFormClosing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ if (m_changed && !Util.YesNo("Lose current edits?"))
+ {
+ e.Cancel=true;
+ }
+ }
+
+ void OnShowDebug(object sender, System.EventArgs e)
+ {
+ if (m_showDebug.Checked)
+ {
+ m_debug.StartDebug();
+ }
+ else
+ {
+ m_debug.StopDebug();
+ }
+ }
+
+ void OnKeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
+ {
+ if (e.KeyCode==Keys.F5)
+ {
+ OnRun(null,null);
+ e.Handled=true;
+ }
+ }
+
+ }
+}
diff --git a/SID.cs b/SID.cs
new file mode 100644
index 0000000..f6496ac
--- /dev/null
+++ b/SID.cs
@@ -0,0 +1,140 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using HardsidInterface;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Description of SID.
+ /// </summary>
+ public class SID
+ {
+ [Flags]
+ public enum ControlFlag
+ {
+ NOISE=128,
+ PULSE=64,
+ SAW=32,
+ TRIANGLE=16,
+ TEST=8,
+ RING=4,
+ SYNC=2,
+ GATE=1,
+ NONE=0
+ };
+
+ [Flags]
+ public enum FilterFlag
+ {
+ OFF3=128,
+ HP=64,
+ BP=32,
+ LP=16,
+ EXT=8,
+ V3=4,
+ V2=2,
+ V1=1,
+ NONE=0
+ };
+
+ public static void Volume(byte volume)
+ {
+ byte v=(byte)(Hardsid.Read(24)&0xf0u);
+
+ v|=volume;
+ Hardsid.Write(24,v);
+ }
+
+ public static void Frequency(byte voice, uint val)
+ {
+ byte r=(byte)(voice*7);
+ byte h=(byte)(val>>8);
+ byte l=(byte)(val&0xff);
+
+ Hardsid.Write(r,l);
+ Hardsid.Write(r+1u,h);
+ }
+
+ public static void PulseWidth(byte voice, uint val)
+ {
+ byte r=(byte)(voice*7);
+ byte h=(byte)(val>>8);
+ byte l=(byte)(val&0xff);
+
+ Hardsid.Write(r+2u,l);
+ Hardsid.Write(r+3u,h);
+ }
+
+ public static void ADSR(byte voice,
+ byte attack, byte decay,
+ byte sustain, byte release)
+ {
+ byte r=(byte)(voice*7);
+ byte ad=(byte)(((attack&0x0fu)<<4)|(decay&0x0fu));
+ byte sr=(byte)(((sustain&0x0fu)<<4)|(release&0x0fu));
+
+ Hardsid.Write(r+5u,ad);
+ Hardsid.Write(r+6u,sr);
+ }
+
+ public static void Control(byte voice, ControlFlag control)
+ {
+ byte r=(byte)(voice*7);
+
+ Hardsid.Write(r+4u,(uint)control);
+ }
+
+ public static void Cutoff(uint val)
+ {
+ byte h=(byte)(val>>3);
+ byte l=(byte)(val&0x7);
+
+ Hardsid.Write(21,l);
+ Hardsid.Write(22+1u,h);
+ }
+
+ public static void Resonance(byte val)
+ {
+ byte v=(byte)(Hardsid.Read(23)&0x0fu);
+
+ v|=(byte)((val&0x0fu)<<4);
+ Hardsid.Write(23,v);
+ }
+
+ public static void Filter(FilterFlag flags)
+ {
+ byte h=(byte)((uint)flags&0xf0u);
+ byte l=(byte)((uint)flags&0x0fu);
+
+ byte v=(byte)(Hardsid.Read(23)&0xf0u);
+
+ v|=l;
+ Hardsid.Write(23,v);
+
+ v=(byte)(Hardsid.Read(24)&0x0fu);
+
+ v|=h;
+ Hardsid.Write(24,v);
+ }
+
+ private SID() {}
+ }
+}
diff --git a/SIDFX.About.resources b/SIDFX.About.resources
new file mode 100644
index 0000000..5e791ce
--- /dev/null
+++ b/SIDFX.About.resources
Binary files differ
diff --git a/SIDFX.DebugForm.resources b/SIDFX.DebugForm.resources
new file mode 100644
index 0000000..bfecae4
--- /dev/null
+++ b/SIDFX.DebugForm.resources
Binary files differ
diff --git a/SIDFX.ExecuteForm.resources b/SIDFX.ExecuteForm.resources
new file mode 100644
index 0000000..32cd2d8
--- /dev/null
+++ b/SIDFX.ExecuteForm.resources
Binary files differ
diff --git a/SIDFX.MainForm.resources b/SIDFX.MainForm.resources
new file mode 100644
index 0000000..f413a6e
--- /dev/null
+++ b/SIDFX.MainForm.resources
Binary files differ
diff --git a/SIDFX.PlayForm.resources b/SIDFX.PlayForm.resources
new file mode 100644
index 0000000..cbcad6a
--- /dev/null
+++ b/SIDFX.PlayForm.resources
Binary files differ
diff --git a/SIDFX.cmbx b/SIDFX.cmbx
new file mode 100644
index 0000000..35fb372
--- /dev/null
+++ b/SIDFX.cmbx
@@ -0,0 +1,24 @@
+<Combine fileversion="1.0" name="SIDFX" description="">
+ <StartMode startupentry="SIDFX" single="True">
+ <Execute entry="SIDFX" type="None" />
+ <Execute entry="Noddybox.GUI" type="None" />
+ <Execute entry="HardsidInterface" type="None" />
+ </StartMode>
+ <Entries>
+ <Entry filename=".\.\SIDFX.prjx" />
+ <Entry filename="..\Noddybox.GUI\Noddybox.GUI.prjx" />
+ <Entry filename="..\HardsidInterface\HardsidInterface.prjx" />
+ </Entries>
+ <Configurations active="Debug">
+ <Configuration name="Release">
+ <Entry name="SIDFX" configurationname="Debug" build="False" />
+ <Entry name="Noddybox.GUI" configurationname="Debug" build="False" />
+ <Entry name="HardsidInterface" configurationname="Debug" build="False" />
+ </Configuration>
+ <Configuration name="Debug">
+ <Entry name="SIDFX" configurationname="Debug" build="False" />
+ <Entry name="Noddybox.GUI" configurationname="Debug" build="False" />
+ <Entry name="HardsidInterface" configurationname="Debug" build="False" />
+ </Configuration>
+ </Configurations>
+</Combine> \ No newline at end of file
diff --git a/SIDFX.prjx b/SIDFX.prjx
new file mode 100644
index 0000000..ee73fb0
--- /dev/null
+++ b/SIDFX.prjx
@@ -0,0 +1,40 @@
+<Project name="SIDFX" standardNamespace="SIDFX" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
+ <Contents>
+ <File name=".\MainForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\SIDFX.MainForm.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name="..\Util.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="..\About.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\SIDFX.About.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name=".\CompileScript.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="..\Help.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name=".\SID.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\ExecuteForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\SIDFX.ExecuteForm.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name=".\DebugForm.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\SIDFX.DebugForm.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name=".\SIDFX.PlayForm.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ </Contents>
+ <References>
+ <Reference type="Project" refto="Noddybox.GUI" localcopy="True" />
+ <Reference type="Project" refto="HardsidInterface" localcopy="True" />
+ </References>
+ <DeploymentInformation target="" script="" strategy="File" />
+ <Configuration runwithwarnings="True" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
+ <Execution commandlineparameters="" consolepause="False" />
+ <Output directory="..\bin\Debug" assembly="SIDFX" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
+ </Configuration>
+ <Configurations active="Debug">
+ <Configuration runwithwarnings="True" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
+ <Execution commandlineparameters="" consolepause="False" />
+ <Output directory="..\bin\Debug" assembly="SIDFX" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
+ </Configuration>
+ <Configuration runwithwarnings="True" name="Release">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="WinExe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
+ <Execution commandlineparameters="" consolepause="False" />
+ <Output directory="..\bin\Release" assembly="SIDFX" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
+ </Configuration>
+ </Configurations>
+</Project> \ No newline at end of file
diff --git a/Util.cs b/Util.cs
new file mode 100644
index 0000000..63ef198
--- /dev/null
+++ b/Util.cs
@@ -0,0 +1,52 @@
+// SIDFX
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program 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.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Windows.Forms;
+using System.Text;
+
+namespace SIDFX
+{
+ /// <summary>
+ /// Usual utils and some state machine
+ /// </summary>
+ public class Util
+ {
+ public static bool YesNo(string s)
+ {
+ return MessageBox.Show(s,"Question",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question)==DialogResult.Yes;
+ }
+
+ public static void Message(string s)
+ {
+ MessageBox.Show(s,"Message",MessageBoxButtons.OK,MessageBoxIcon.Information);
+ }
+
+ public static void Error(string s)
+ {
+ MessageBox.Show(s,"ERROR",MessageBoxButtons.OK,MessageBoxIcon.Error);
+ }
+
+ private Util()
+ {
+ }
+ }
+}
diff --git a/help.rtf b/help.rtf
new file mode 100644
index 0000000..630623e
--- /dev/null
+++ b/help.rtf
Binary files differ