├── EAGLEproject
├── CAPACITOR_LEAD.lbr
├── CAPACITOR_P_LEAD.lbr
├── MINI_SW.lbr
├── MTM05_R1d2.PNG
├── OPAMP.lbr
├── OSC_HALF.lbr
├── PINHEADER.lbr
├── POWER.lbr
├── Photocoupler.lbr
├── RESISTER_H_LEAD.lbr
├── YM2151.lbr
├── YM2151ShieldR3.brd
├── YM2151ShieldR3.sch
├── YM3012.lbr
└── arduino.lbr
├── FileUploader
├── release
│ └── ArduinoFileUploader_2018Jul.zip
└── src
│ ├── ArduinoFileUploader.csproj
│ ├── ArduinoFileUploader.sln
│ ├── Forms
│ ├── AboutThisProgramForm.Designer.cs
│ ├── AboutThisProgramForm.cs
│ ├── AboutThisProgramForm.en.resx
│ ├── AboutThisProgramForm.ja.resx
│ ├── AboutThisProgramForm.resx
│ ├── AutoLoadSettings.Designer.cs
│ ├── AutoLoadSettings.cs
│ ├── AutoLoadSettings.en.resx
│ ├── AutoLoadSettings.ja.resx
│ ├── AutoLoadSettings.resx
│ ├── MainForm.Designer.cs
│ ├── MainForm.cs
│ ├── MainForm.en.resx
│ ├── MainForm.ja.resx
│ └── MainForm.resx
│ ├── IntelHEX.cs
│ ├── License.txt
│ ├── MDXTinyParser.cs
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ ├── Settings.settings
│ └── app.manifest
│ ├── Readme.txt
│ ├── Resources
│ ├── Strings.Designer.cs
│ ├── Strings.en.resx
│ ├── Strings.ja.resx
│ ├── Strings.resx
│ └── boards.xml
│ └── STK500.cs
├── SketchMDXPlayer
├── Common.h
├── IO.cpp
├── IO.h
├── License.txt
├── MDXParser.cpp
├── MDXParser.h
├── MMLParser.cpp
├── MMLParser.h
├── Readme.txt
├── SketchMDXPlayer.pde
├── YM2151.cpp
└── YM2151.h
├── YM2151ShieldKitManual-0.1.pdf
├── YM2151ShieldKitManual_EN-0.1.pdf
└── YM2151ShieldR3Gerber.zip
/EAGLEproject/CAPACITOR_LEAD.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/CAPACITOR_LEAD.lbr
--------------------------------------------------------------------------------
/EAGLEproject/CAPACITOR_P_LEAD.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/CAPACITOR_P_LEAD.lbr
--------------------------------------------------------------------------------
/EAGLEproject/MINI_SW.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/MINI_SW.lbr
--------------------------------------------------------------------------------
/EAGLEproject/MTM05_R1d2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/MTM05_R1d2.PNG
--------------------------------------------------------------------------------
/EAGLEproject/OPAMP.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/OPAMP.lbr
--------------------------------------------------------------------------------
/EAGLEproject/OSC_HALF.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/OSC_HALF.lbr
--------------------------------------------------------------------------------
/EAGLEproject/PINHEADER.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/PINHEADER.lbr
--------------------------------------------------------------------------------
/EAGLEproject/POWER.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/POWER.lbr
--------------------------------------------------------------------------------
/EAGLEproject/Photocoupler.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/Photocoupler.lbr
--------------------------------------------------------------------------------
/EAGLEproject/RESISTER_H_LEAD.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/RESISTER_H_LEAD.lbr
--------------------------------------------------------------------------------
/EAGLEproject/YM2151.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/YM2151.lbr
--------------------------------------------------------------------------------
/EAGLEproject/YM2151ShieldR3.brd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/YM2151ShieldR3.brd
--------------------------------------------------------------------------------
/EAGLEproject/YM2151ShieldR3.sch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/YM2151ShieldR3.sch
--------------------------------------------------------------------------------
/EAGLEproject/YM3012.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/YM3012.lbr
--------------------------------------------------------------------------------
/EAGLEproject/arduino.lbr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/EAGLEproject/arduino.lbr
--------------------------------------------------------------------------------
/FileUploader/release/ArduinoFileUploader_2018Jul.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/FileUploader/release/ArduinoFileUploader_2018Jul.zip
--------------------------------------------------------------------------------
/FileUploader/src/ArduinoFileUploader.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {4A60CF5E-2D68-4779-88FC-73677F6B8962}
9 | WinExe
10 | Properties
11 | ArduinoFileUploader
12 | ArduinoFileUploader
13 | v3.5
14 | 512
15 | false
16 | E784C7E03087BCBEBBC7C246BD1755496262703A
17 | ArduinoFileUploader_TemporaryKey.pfx
18 | false
19 | LocalIntranet
20 | Properties\app.manifest
21 | false
22 |
23 |
24 |
25 |
26 | 3.5
27 | E:\project\YM2151\Release\
28 | true
29 | Disk
30 | false
31 | Foreground
32 | 7
33 | Days
34 | false
35 | false
36 | true
37 | 1
38 | 0.3.0.1
39 | false
40 | true
41 |
42 |
43 | true
44 | full
45 | false
46 | bin\Debug\
47 | DEBUG;TRACE
48 | prompt
49 | 4
50 |
51 |
52 | pdbonly
53 | true
54 | bin\Release\
55 | TRACE
56 | prompt
57 | 4
58 |
59 |
60 |
61 |
62 | 3.5
63 |
64 |
65 | 3.5
66 |
67 |
68 | 3.5
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | Form
79 |
80 |
81 | AboutThisProgramForm.cs
82 |
83 |
84 | Form
85 |
86 |
87 | AutoLoadSettings.cs
88 |
89 |
90 | Form
91 |
92 |
93 | MainForm.cs
94 |
95 |
96 |
97 |
98 |
99 |
100 | AboutThisProgramForm.cs
101 |
102 |
103 | AboutThisProgramForm.cs
104 |
105 |
106 | AboutThisProgramForm.cs
107 |
108 |
109 | AutoLoadSettings.cs
110 |
111 |
112 | AutoLoadSettings.cs
113 |
114 |
115 | AutoLoadSettings.cs
116 |
117 |
118 | MainForm.cs
119 |
120 |
121 | MainForm.cs
122 |
123 |
124 | MainForm.cs
125 |
126 |
127 | ResXFileCodeGenerator
128 | Resources.Designer.cs
129 | Designer
130 |
131 |
132 | Designer
133 |
134 |
135 | Designer
136 |
137 |
138 | ResXFileCodeGenerator
139 | Strings.Designer.cs
140 | Designer
141 |
142 |
143 | True
144 | Resources.resx
145 | True
146 |
147 |
148 |
149 | SettingsSingleFileGenerator
150 | Settings.Designer.cs
151 |
152 |
153 | True
154 | Settings.settings
155 | True
156 |
157 |
158 | True
159 | True
160 | Strings.resx
161 |
162 |
163 |
164 |
165 |
166 | False
167 | .NET Framework 2.0 %28x86%29
168 | false
169 |
170 |
171 | False
172 | .NET Framework 3.0 %28x86%29
173 | false
174 |
175 |
176 | False
177 | .NET Framework 3.5
178 | true
179 |
180 |
181 | False
182 | .NET Framework 3.5 SP1
183 | false
184 |
185 |
186 | False
187 | Windows インストーラ 3.1
188 | true
189 |
190 |
191 |
192 |
193 |
194 |
195 |
202 |
--------------------------------------------------------------------------------
/FileUploader/src/ArduinoFileUploader.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2042
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C81B4103-BD38-4FF6-AC1D-06106C578928}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArduinoFileUploader", "ArduinoFileUploader.csproj", "{4A60CF5E-2D68-4779-88FC-73677F6B8962}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {4A60CF5E-2D68-4779-88FC-73677F6B8962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {4A60CF5E-2D68-4779-88FC-73677F6B8962}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {4A60CF5E-2D68-4779-88FC-73677F6B8962}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {4A60CF5E-2D68-4779-88FC-73677F6B8962}.Release|Any CPU.Build.0 = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(SolutionProperties) = preSolution
22 | HideSolutionNode = FALSE
23 | EndGlobalSection
24 | GlobalSection(ExtensibilityGlobals) = postSolution
25 | SolutionGuid = {088DA781-DB71-4244-ABF9-B06B4926ABD7}
26 | EndGlobalSection
27 | EndGlobal
28 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AboutThisProgramForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ArduinoFileUploader
2 | {
3 | partial class AboutThisProgramForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutThisProgramForm));
32 | this.button1 = new System.Windows.Forms.Button();
33 | this.label1 = new System.Windows.Forms.Label();
34 | this.label2 = new System.Windows.Forms.Label();
35 | this.linkLabel1 = new System.Windows.Forms.LinkLabel();
36 | this.SuspendLayout();
37 | //
38 | // button1
39 | //
40 | this.button1.AccessibleDescription = null;
41 | this.button1.AccessibleName = null;
42 | resources.ApplyResources(this.button1, "button1");
43 | this.button1.BackgroundImage = null;
44 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
45 | this.button1.Font = null;
46 | this.button1.Name = "button1";
47 | this.button1.UseVisualStyleBackColor = true;
48 | //
49 | // label1
50 | //
51 | this.label1.AccessibleDescription = null;
52 | this.label1.AccessibleName = null;
53 | resources.ApplyResources(this.label1, "label1");
54 | this.label1.Font = null;
55 | this.label1.Name = "label1";
56 | //
57 | // label2
58 | //
59 | this.label2.AccessibleDescription = null;
60 | this.label2.AccessibleName = null;
61 | resources.ApplyResources(this.label2, "label2");
62 | this.label2.Font = null;
63 | this.label2.Name = "label2";
64 | //
65 | // linkLabel1
66 | //
67 | this.linkLabel1.AccessibleDescription = null;
68 | this.linkLabel1.AccessibleName = null;
69 | resources.ApplyResources(this.linkLabel1, "linkLabel1");
70 | this.linkLabel1.Font = null;
71 | this.linkLabel1.Name = "linkLabel1";
72 | this.linkLabel1.TabStop = true;
73 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
74 | //
75 | // AboutThisProgramForm
76 | //
77 | this.AccessibleDescription = null;
78 | this.AccessibleName = null;
79 | resources.ApplyResources(this, "$this");
80 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
81 | this.BackgroundImage = null;
82 | this.Controls.Add(this.linkLabel1);
83 | this.Controls.Add(this.label2);
84 | this.Controls.Add(this.label1);
85 | this.Controls.Add(this.button1);
86 | this.Font = null;
87 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
88 | this.Icon = null;
89 | this.Name = "AboutThisProgramForm";
90 | this.ResumeLayout(false);
91 |
92 | }
93 |
94 | #endregion
95 |
96 | private System.Windows.Forms.Button button1;
97 | private System.Windows.Forms.Label label1;
98 | private System.Windows.Forms.Label label2;
99 | private System.Windows.Forms.LinkLabel linkLabel1;
100 | }
101 | }
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AboutThisProgramForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 |
10 | namespace ArduinoFileUploader
11 | {
12 | public partial class AboutThisProgramForm : Form
13 | {
14 | public AboutThisProgramForm()
15 | {
16 | InitializeComponent();
17 | label2.Text = Resources.Strings.Version;
18 | linkLabel1.Text = Resources.Strings.HomePage;
19 | this.Refresh();
20 | }
21 |
22 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
23 | {
24 | linkLabel1.LinkVisited = true;
25 | System.Diagnostics.Process.Start(Resources.Strings.HomePage);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AboutThisProgramForm.en.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | About ArduinoFileUploader
122 |
123 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AboutThisProgramForm.ja.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | ArduinoFileUploaderついて
122 |
123 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AboutThisProgramForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | label2
122 |
123 |
124 |
125 | 200, 12
126 |
127 |
128 | button1
129 |
130 |
131 |
132 | None
133 |
134 |
135 | 2
136 |
137 |
138 | 200, 12
139 |
140 |
141 | 91, 69
142 |
143 |
144 | None
145 |
146 |
147 | label2
148 |
149 |
150 | ArduinoFileUploader
151 |
152 |
153 | System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
154 |
155 |
156 | このプログラムについて
157 |
158 |
159 | 200, 12
160 |
161 |
162 | 3
163 |
164 |
165 | None
166 |
167 |
168 | 0
169 |
170 |
171 | System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
172 |
173 |
174 | Top, Bottom
175 |
176 |
177 | System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
178 |
179 |
180 | System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
181 |
182 |
183 | System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
184 |
185 |
186 | MiddleCenter
187 |
188 |
189 | 29, 28
190 |
191 |
192 |
193 | 2
194 |
195 |
196 | 75, 23
197 |
198 |
199 | 259, 95
200 |
201 |
202 | linkLabel1
203 |
204 |
205 | $this
206 |
207 |
208 | 29, 9
209 |
210 |
211 | MiddleCenter
212 |
213 |
214 | label1
215 |
216 |
217 | 1
218 |
219 |
220 | linkLabel1
221 |
222 |
223 | Ok
224 |
225 |
226 | $this
227 |
228 |
229 | 1
230 |
231 |
232 | MiddleCenter
233 |
234 |
235 | 3
236 |
237 |
238 | 0
239 |
240 |
241 | $this
242 |
243 |
244 | 29, 40
245 |
246 |
247 | 6, 12
248 |
249 |
250 | $this
251 |
252 |
253 | AboutThisProgramForm
254 |
255 |
256 | True
257 |
258 |
259 | English
260 |
261 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AutoLoadSettings.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ArduinoFileUploader
2 | {
3 | partial class AutoLoadSettings
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AutoLoadSettings));
32 | this.button1 = new System.Windows.Forms.Button();
33 | this.button2 = new System.Windows.Forms.Button();
34 | this.textBox1 = new System.Windows.Forms.TextBox();
35 | this.button3 = new System.Windows.Forms.Button();
36 | this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
37 | this.label1 = new System.Windows.Forms.Label();
38 | this.label2 = new System.Windows.Forms.Label();
39 | this.label3 = new System.Windows.Forms.Label();
40 | this.textBox2 = new System.Windows.Forms.TextBox();
41 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
42 | this.SuspendLayout();
43 | //
44 | // button1
45 | //
46 | this.button1.AccessibleDescription = null;
47 | this.button1.AccessibleName = null;
48 | resources.ApplyResources(this.button1, "button1");
49 | this.button1.BackgroundImage = null;
50 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
51 | this.button1.Font = null;
52 | this.button1.Name = "button1";
53 | this.button1.UseVisualStyleBackColor = true;
54 | //
55 | // button2
56 | //
57 | this.button2.AccessibleDescription = null;
58 | this.button2.AccessibleName = null;
59 | resources.ApplyResources(this.button2, "button2");
60 | this.button2.BackgroundImage = null;
61 | this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
62 | this.button2.Font = null;
63 | this.button2.Name = "button2";
64 | this.button2.UseVisualStyleBackColor = true;
65 | //
66 | // textBox1
67 | //
68 | this.textBox1.AccessibleDescription = null;
69 | this.textBox1.AccessibleName = null;
70 | resources.ApplyResources(this.textBox1, "textBox1");
71 | this.textBox1.BackgroundImage = null;
72 | this.textBox1.Font = null;
73 | this.textBox1.Name = "textBox1";
74 | //
75 | // button3
76 | //
77 | this.button3.AccessibleDescription = null;
78 | this.button3.AccessibleName = null;
79 | resources.ApplyResources(this.button3, "button3");
80 | this.button3.BackgroundImage = null;
81 | this.button3.Font = null;
82 | this.button3.Name = "button3";
83 | this.button3.UseVisualStyleBackColor = true;
84 | this.button3.Click += new System.EventHandler(this.button3_Click);
85 | //
86 | // numericUpDown1
87 | //
88 | this.numericUpDown1.AccessibleDescription = null;
89 | this.numericUpDown1.AccessibleName = null;
90 | resources.ApplyResources(this.numericUpDown1, "numericUpDown1");
91 | this.numericUpDown1.Font = null;
92 | this.numericUpDown1.Name = "numericUpDown1";
93 | //
94 | // label1
95 | //
96 | this.label1.AccessibleDescription = null;
97 | this.label1.AccessibleName = null;
98 | resources.ApplyResources(this.label1, "label1");
99 | this.label1.Font = null;
100 | this.label1.Name = "label1";
101 | //
102 | // label2
103 | //
104 | this.label2.AccessibleDescription = null;
105 | this.label2.AccessibleName = null;
106 | resources.ApplyResources(this.label2, "label2");
107 | this.label2.Font = null;
108 | this.label2.Name = "label2";
109 | //
110 | // label3
111 | //
112 | this.label3.AccessibleDescription = null;
113 | this.label3.AccessibleName = null;
114 | resources.ApplyResources(this.label3, "label3");
115 | this.label3.Font = null;
116 | this.label3.Name = "label3";
117 | //
118 | // textBox2
119 | //
120 | this.textBox2.AccessibleDescription = null;
121 | this.textBox2.AccessibleName = null;
122 | resources.ApplyResources(this.textBox2, "textBox2");
123 | this.textBox2.BackgroundImage = null;
124 | this.textBox2.Font = null;
125 | this.textBox2.Name = "textBox2";
126 | //
127 | // AutoLoadSettings
128 | //
129 | this.AccessibleDescription = null;
130 | this.AccessibleName = null;
131 | resources.ApplyResources(this, "$this");
132 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
133 | this.BackgroundImage = null;
134 | this.Controls.Add(this.textBox2);
135 | this.Controls.Add(this.label3);
136 | this.Controls.Add(this.label2);
137 | this.Controls.Add(this.label1);
138 | this.Controls.Add(this.numericUpDown1);
139 | this.Controls.Add(this.button3);
140 | this.Controls.Add(this.textBox1);
141 | this.Controls.Add(this.button2);
142 | this.Controls.Add(this.button1);
143 | this.Font = null;
144 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
145 | this.Icon = null;
146 | this.MaximizeBox = false;
147 | this.MinimizeBox = false;
148 | this.Name = "AutoLoadSettings";
149 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
150 | this.ResumeLayout(false);
151 | this.PerformLayout();
152 |
153 | }
154 |
155 | #endregion
156 |
157 | private System.Windows.Forms.Button button1;
158 | private System.Windows.Forms.Button button2;
159 | private System.Windows.Forms.TextBox textBox1;
160 | private System.Windows.Forms.Button button3;
161 | private System.Windows.Forms.NumericUpDown numericUpDown1;
162 | private System.Windows.Forms.Label label1;
163 | private System.Windows.Forms.Label label2;
164 | private System.Windows.Forms.Label label3;
165 | private System.Windows.Forms.TextBox textBox2;
166 | }
167 | }
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AutoLoadSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 |
10 | namespace ArduinoFileUploader
11 | {
12 | public partial class AutoLoadSettings : Form
13 | {
14 | public string FolderName
15 | {
16 | get
17 | {
18 | return textBox1.Text;
19 | }
20 | set
21 | {
22 | textBox1.Text = value;
23 | }
24 | }
25 | public int IntervalTime
26 | {
27 | get
28 | {
29 | return Decimal.ToInt32(numericUpDown1.Value);
30 | }
31 | set
32 | {
33 | numericUpDown1.Value = value;
34 | }
35 | }
36 | public string FileFilter
37 | {
38 | get
39 | {
40 | return textBox2.Text;
41 | }
42 | set
43 | {
44 | textBox2.Text = value;
45 | }
46 | }
47 | public AutoLoadSettings()
48 | {
49 | InitializeComponent();
50 | }
51 |
52 | private void button3_Click(object sender, EventArgs e)
53 | {
54 | System.Windows.Forms.FolderBrowserDialog diag = new FolderBrowserDialog();
55 | if (diag.ShowDialog() == DialogResult.OK)
56 | {
57 | textBox1.Text = diag.SelectedPath;
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AutoLoadSettings.en.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Apply
122 |
123 |
124 | Cancel
125 |
126 |
127 |
128 | 466, 19
129 |
130 |
131 | 484, 31
132 |
133 |
134 | 90, 23
135 |
136 |
137 | Select Folder
138 |
139 |
140 | 78, 12
141 |
142 |
143 | Search Folder:
144 |
145 |
146 | 72, 12
147 |
148 |
149 | Interval(Sec):
150 |
151 |
152 | 142, 60
153 |
154 |
155 | 53, 12
156 |
157 |
158 | FileFilter:
159 |
160 |
161 | 144, 78
162 |
163 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AutoLoadSettings.ja.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | 499, 100
123 |
124 |
125 | 407, 100
126 |
127 |
128 | 83, 12
129 |
130 |
131 | インターバル(秒):
132 |
133 |
134 | 146, 60
135 |
136 |
137 | 139, 78
138 |
139 |
140 | 582, 130
141 |
142 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/AutoLoadSettings.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
122 |
123 |
124 | 7
125 |
126 |
127 |
128 | 80, 12
129 |
130 |
131 | 13, 78
132 |
133 |
134 | $this
135 |
136 |
137 |
138 | True
139 |
140 |
141 | 3
142 |
143 |
144 | 1
145 |
146 |
147 | label2
148 |
149 |
150 | 5
151 |
152 |
153 | 582, 145
154 |
155 |
156 | textBox2
157 |
158 |
159 | 4
160 |
161 |
162 | System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
163 |
164 |
165 | 499, 31
166 |
167 |
168 | 7
169 |
170 |
171 | AutoLoadSettings
172 |
173 |
174 | 75, 23
175 |
176 |
177 | 参照
178 |
179 |
180 | 8
181 |
182 |
183 | 2
184 |
185 |
186 | button2
187 |
188 |
189 | 3
190 |
191 |
192 | System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
193 |
194 |
195 | 6
196 |
197 |
198 | $this
199 |
200 |
201 | 407, 110
202 |
203 |
204 | 12, 33
205 |
206 |
207 | $this
208 |
209 |
210 | 90, 12
211 |
212 |
213 | 0
214 |
215 |
216 | True
217 |
218 |
219 | インターバル(Sec):
220 |
221 |
222 | $this
223 |
224 |
225 | ファイルのフィルタ:
226 |
227 |
228 | $this
229 |
230 |
231 | 6
232 |
233 |
234 | 84, 12
235 |
236 |
237 | numericUpDown1
238 |
239 |
240 | AutoLoadSettings
241 |
242 |
243 | $this
244 |
245 |
246 | 設定
247 |
248 |
249 | label3
250 |
251 |
252 | textBox1
253 |
254 |
255 | $this
256 |
257 |
258 | label1
259 |
260 |
261 | button1
262 |
263 |
264 | 13, 15
265 |
266 |
267 | 120, 19
268 |
269 |
270 | 15, 60
271 |
272 |
273 | 75, 23
274 |
275 |
276 | 2
277 |
278 |
279 | $this
280 |
281 |
282 | System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
283 |
284 |
285 | $this
286 |
287 |
288 | 75, 23
289 |
290 |
291 | 4
292 |
293 |
294 | System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
295 |
296 |
297 | System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
298 |
299 |
300 | System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
301 |
302 |
303 | System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
304 |
305 |
306 | 470, 19
307 |
308 |
309 | 100, 19
310 |
311 |
312 | 5
313 |
314 |
315 | 179, 60
316 |
317 |
318 | button3
319 |
320 |
321 | キャンセル
322 |
323 |
324 | System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
325 |
326 |
327 | 8
328 |
329 |
330 | 6, 12
331 |
332 |
333 | True
334 |
335 |
336 | 181, 78
337 |
338 |
339 | 499, 110
340 |
341 |
342 | System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
343 |
344 |
345 | 1
346 |
347 |
348 | 実行ディレクトリ:
349 |
350 |
351 | 0
352 |
353 |
354 | True
355 |
356 |
357 | Japanese
358 |
359 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.Threading;
10 |
11 | namespace ArduinoFileUploader
12 | {
13 | public partial class MainForm : Form
14 | {
15 | STK500 STK500Ctrl = new STK500();
16 | System.Windows.Forms.Timer AutoLoaderTimer = new System.Windows.Forms.Timer();
17 | int AutoLoaderInterval = 60;
18 | string AutoLoaderPath = null;
19 | string AutoLoaderFilter = "*.mdx";
20 | string[] AutoLoaderFiles;
21 | int AutoLoaderIndex;
22 | List BoardList = new List();
23 | Board CurrentBord=null;
24 | List BoardListMenuItem = new List();
25 | public MainForm()
26 | {
27 | LoadBoardList();
28 | InitializeComponent();
29 | scanningSerialPort();
30 | careateBoardListMenuItem();
31 | restoreRegistry();
32 | updateStatus();
33 | comboBox2.SelectedIndex = 0;
34 | STK500Ctrl.StateCallback += new STK500.StateCallbackMethod(updateStatus);
35 | STK500Ctrl.ReciveCallback += new STK500.ReciveCallbackMethod(ReciveData);
36 | AutoLoaderTimer.Tick += new EventHandler(FormTimer_Tick);
37 | }
38 |
39 | void FormTimer_Tick(object sender, EventArgs e)
40 | {
41 | if (STK500Ctrl.IsRunningCritical || STK500Ctrl.CountMessage() > 0)
42 | {
43 | AutoLoaderTimer.Interval = AutoLoaderInterval * 1000;
44 | return;
45 | }
46 | System.Text.StringBuilder sb = new System.Text.StringBuilder();
47 | AutoLoaderTimer.Interval = AutoLoaderInterval * 1000;
48 | sb.Append("Loading..");
49 | sb.Append(AutoLoaderFiles[AutoLoaderIndex]);
50 | sb.Append(System.Environment.NewLine);
51 | textBox1.AppendText(sb.ToString());
52 | if (!sendImage(null, AutoLoaderFiles[AutoLoaderIndex], true))
53 | {
54 | AutoLoaderTimer.Stop();
55 | MessageBox.Show(Resources.Strings.ErrorMessage_AutoLoad);
56 | return;
57 | }
58 | AutoLoaderIndex++;
59 | if (AutoLoaderIndex >= AutoLoaderFiles.Length) AutoLoaderIndex = 0;
60 | }
61 |
62 | delegate void UpdateStatusDelegate();
63 | private void updateStatus()
64 | {
65 | if (InvokeRequired)
66 | {
67 | Invoke(new UpdateStatusDelegate(updateStatus));
68 | return;
69 | }
70 | if (AutoLoaderTimer.Enabled && STK500Ctrl.MainState == STK500.MainStateEnum.Abort)
71 | {
72 | AutoLoaderTimer.Stop();
73 | }
74 | if (STK500Ctrl.IsRunningCritical)
75 | {
76 | if(button3.Enabled)
77 | button3.Enabled = false;
78 | }
79 | else
80 | {
81 | if(!button3.Enabled)
82 | button3.Enabled = true;
83 | }
84 | if (AutoLoaderTimer.Enabled && !AutoLoadToolStripMenuItem.Checked)
85 | {
86 | button3.Enabled = false;
87 | AutoLoadToolStripMenuItem.Checked = true;
88 | }
89 | if (!AutoLoaderTimer.Enabled && AutoLoadToolStripMenuItem.Checked)
90 | {
91 | button3.Enabled = true;
92 | AutoLoadToolStripMenuItem.Checked = false;
93 | }
94 | switch (STK500Ctrl.MainState)
95 | {
96 | case STK500.MainStateEnum.Reset:
97 | toolStripStatusLabel1.Text = STK500Ctrl.MainState.ToString();
98 | break;
99 | case STK500.MainStateEnum.Send:
100 | toolStripStatusLabel1.Text = STK500Ctrl.MainState.ToString() + String.Format(":{0}/{1}", STK500Ctrl.RecordIndex+1, STK500Ctrl.RecordCount);
101 | toolStripProgressBar1.Value = (int)(STK500Ctrl.RecordProcessing * 100f);
102 | break;
103 | case STK500.MainStateEnum.Verify:
104 | toolStripStatusLabel1.Text = STK500Ctrl.MainState.ToString() + String.Format(":{0}/{1}", STK500Ctrl.RecordIndex+1, STK500Ctrl.RecordCount);
105 | toolStripProgressBar1.Value = (int)(STK500Ctrl.RecordProcessing * 100f);
106 | break;
107 | default:
108 | toolStripStatusLabel1.Text = STK500Ctrl.MainState.ToString()+':'+STK500Ctrl.ErrorState.ToString();
109 | if (AutoLoaderTimer.Enabled)
110 | {
111 | toolStripStatusLabel1.Text += String.Format(" ..AutoRun({0}/{1})",AutoLoaderIndex+1,AutoLoaderFiles.Length);
112 | }
113 | toolStripProgressBar1.Value = 0;
114 | break;
115 | }
116 | foreach (ToolStripMenuItem item in BoardListMenuItem)
117 | {
118 | if (item.Tag == (object)CurrentBord)
119 | { item.Checked = true; }
120 | else { item.Checked = false; }
121 | }
122 |
123 | statusStrip1.Invalidate();
124 | }
125 |
126 | delegate void ReciveDataDelegate(string str);
127 | private void ReciveData(string str){
128 | if (InvokeRequired)
129 | {
130 | Invoke(new ReciveDataDelegate(ReciveData),str);
131 | return;
132 | }
133 | textBox1.AppendText(str);
134 | }
135 |
136 | private void scanningSerialPort()
137 | {
138 | comboBox1.Items.Clear();
139 | string[] portnames = System.IO.Ports.SerialPort.GetPortNames();
140 | foreach (string str in portnames)
141 | {
142 | comboBox1.Items.Add(str);
143 | }
144 | if (portnames == null || portnames.Length ==0)
145 | {
146 | comboBox1.Enabled = false;
147 | }
148 | else
149 | {
150 | comboBox1.Enabled = true;
151 | comboBox1.SelectedIndex = 0;
152 | }
153 | }
154 |
155 | private void careateBoardListMenuItem()
156 | {
157 | foreach (Board board in BoardList)
158 | {
159 | ToolStripMenuItem menuitem = new ToolStripMenuItem(board.Name);
160 | menuitem.Tag = (object)board;
161 | menuitem.Click += new EventHandler(DeviceTypeMenuItem_Click);
162 | DeviceTypeToolStripMenuItem.DropDown.Items.Add(menuitem);
163 | BoardListMenuItem.Add(menuitem);
164 | }
165 | }
166 |
167 | private bool sendImage(string hexname, string upfilename,bool poperror)
168 | {
169 | if(CurrentBord==null){
170 | if (poperror) MessageBox.Show(Resources.Strings.ErrorMessage_BordNotSpecified);
171 | return false;
172 | }
173 | if (STK500Ctrl.IsRunningCritical)
174 | {
175 | if (poperror) MessageBox.Show(Resources.Strings.ErrorMessage_RunningWorkerThread);
176 | return false;
177 | }
178 | if (STK500Ctrl.CountMessage() > 0)
179 | {
180 | if (poperror) MessageBox.Show(Resources.Strings.ErrorMessage_RunningWorkerThread);
181 | return false;
182 | }
183 | button3.Enabled = false;
184 | STK500.DataRecord code_recoed = null;
185 | STK500.DataRecord data_recoed = null;
186 | if (hexname!=null && System.IO.File.Exists(hexname))
187 | {
188 | IntelHEX target_code = new IntelHEX(hexname);
189 | code_recoed = new STK500.DataRecord();
190 | code_recoed.Address = target_code.StartAddress;
191 | code_recoed.Data = target_code.Data;
192 | code_recoed.Verify = checkBox3.Checked;
193 | if (target_code.StartAddress + target_code.Data.Length > numericUpDown1.Value)
194 | {
195 | if(poperror) MessageBox.Show(Resources.Strings.ErrorMessage_CodeTooLarge);
196 | button3.Enabled = true;
197 | return false;
198 | }
199 | }
200 | if (upfilename != null && System.IO.File.Exists(upfilename))
201 | {
202 | System.IO.FileStream fs = new System.IO.FileStream(upfilename, System.IO.FileMode.Open);
203 | int file_size = (int)fs.Length;
204 | byte[] file_image = new byte[file_size + 1];
205 | fs.Read(file_image, 0, (int)file_size);
206 | fs.Close();
207 |
208 | if (System.IO.Path.GetExtension(upfilename).ToLower() == ".mdx")
209 | { // If uploading file is mdx than getting file infomation.
210 | MDXTinyParser mdx_parser = new MDXTinyParser(file_image);
211 | toolStripStatusLabel2.Text = mdx_parser.GetTitle();
212 | }
213 | else
214 | {
215 | toolStripStatusLabel2.Text = "--No MDX--";
216 | }
217 |
218 | data_recoed = new STK500.DataRecord();
219 | data_recoed.Address = Decimal.ToInt32(numericUpDown1.Value);
220 | data_recoed.Data = file_image;
221 | data_recoed.Verify = checkBox3.Checked;
222 | if (numericUpDown1.Value + file_size > CurrentBord.BootLoaderAddress)
223 | {
224 | if (poperror) MessageBox.Show(Resources.Strings.ErrorMessage_UploadTooLarge);
225 | button3.Enabled = true;
226 | return false;
227 | }
228 | }
229 | else
230 | {
231 | toolStripStatusLabel2.Text = "--No MDX--";
232 | }
233 | if (code_recoed == null && data_recoed == null)
234 | {
235 | if(poperror) MessageBox.Show(Resources.Strings.ErrorMessage_DataNotExist);
236 | button3.Enabled = true;
237 | return false;
238 | }
239 | pushSerialSetup();
240 | if (code_recoed != null)
241 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.SetRecord, (object)code_recoed));
242 | if (data_recoed != null)
243 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.SetRecord, (object)data_recoed));
244 |
245 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.Start));
246 | STK500Ctrl.AwakeWorker();
247 | updateStatus();
248 | return true;
249 | }
250 |
251 | private void pushSerialSetup()
252 | {
253 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.Clear));
254 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.SetPortName, (object)comboBox1.SelectedItem.ToString()));
255 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.SetDevice, (object)CurrentBord));
256 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.SetAfterWait, (object)checkBox4.Checked));
257 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.SetBaud, (object)Convert.ToInt32(comboBox2.SelectedItem)));
258 | }
259 |
260 | private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
261 | {
262 | storeRegistry();
263 | STK500Ctrl.AbortThread();
264 | }
265 |
266 | // UI callback
267 | private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
268 | {
269 | Application.Exit();
270 | }
271 |
272 | private void TargetResetToolStripMenuItem_Click(object sender, EventArgs e)
273 | {
274 | pushSerialSetup();
275 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.Start));
276 | STK500Ctrl.AwakeWorker();
277 | updateStatus();
278 | }
279 |
280 | private void RescanSerialPortToolStripMenuItem_Click(object sender, EventArgs e)
281 | {
282 | scanningSerialPort();
283 | }
284 |
285 | private void button1_Click(object sender, EventArgs e)
286 | {
287 | System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();
288 | fd.CheckFileExists = true;
289 | fd.Filter = "TargetCode HEX file (*.hex)|*.hex";
290 | if (fd.ShowDialog() == DialogResult.OK && fd.CheckFileExists)
291 | {
292 | textBox_TargetCode.Text = fd.FileName;
293 | checkBox1.Checked = true;
294 | }
295 | }
296 |
297 | private void button2_Click(object sender, EventArgs e)
298 | {
299 | System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();
300 | fd.CheckFileExists = true;
301 | fd.Filter = "Upload file (*.*)|*.*";
302 | if (fd.ShowDialog() == DialogResult.OK && fd.CheckFileExists)
303 | {
304 | textBox_UploadFile.Text = fd.FileName;
305 | checkBox2.Checked = true;
306 | }
307 | }
308 |
309 | private void button3_Click(object sender, EventArgs e)
310 | {
311 | string codefile = null;
312 | string mdxfile = null;
313 | if (textBox_TargetCode.Text.Length > 0 && checkBox1.Checked)
314 | {
315 | codefile = textBox_TargetCode.Text;
316 | }
317 | if (textBox_UploadFile.Text.Length > 0 && checkBox2.Checked)
318 | {
319 | mdxfile = textBox_UploadFile.Text;
320 | }
321 | if (sendImage(codefile, mdxfile, true))
322 | updateStatus();
323 | }
324 |
325 | private void ExitSerialMonitorToolStripMenuItem_Click(object sender, EventArgs e)
326 | {
327 | STK500Ctrl.PushMessage(new STK500.MessageRecord(STK500.MessageRecord.MsgType.Clear));
328 | }
329 |
330 | private void AutoLoadSettingToolStripMenuItem_Click(object sender, EventArgs e)
331 | {
332 | AutoLoadSettings setting = new AutoLoadSettings();
333 | setting.IntervalTime = AutoLoaderInterval;
334 | setting.FolderName = AutoLoaderPath;
335 | setting.FileFilter = AutoLoaderFilter;
336 | if (setting.ShowDialog() == DialogResult.OK)
337 | {
338 | AutoLoaderInterval = setting.IntervalTime;
339 | AutoLoaderPath = setting.FolderName;
340 | AutoLoaderFilter = setting.FileFilter;
341 | }
342 | }
343 |
344 | private void AutoLoadToolStripMenuItem_Click(object sender, EventArgs e)
345 | {
346 | AutoLoaderFiles = System.IO.Directory.GetFiles(AutoLoaderPath, "*.mdx", System.IO.SearchOption.TopDirectoryOnly);
347 | if (AutoLoaderFiles == null || AutoLoaderFiles.Length == 0)
348 | {
349 | MessageBox.Show(Resources.Strings.ErrorMessage_DirectoryNotFound);
350 | return;
351 | }
352 | if (AutoLoaderTimer.Enabled)
353 | {
354 | AutoLoaderTimer.Stop();
355 | }
356 | else
357 | {
358 | AutoLoaderTimer.Interval = 1000;
359 | AutoLoaderIndex = 0;
360 | AutoLoaderTimer.Start();
361 | }
362 | updateStatus();
363 | }
364 |
365 | private void AboutThisProgramToolStripMenuItem_Click(object sender, EventArgs e)
366 | {
367 | AboutThisProgramForm form = new AboutThisProgramForm();
368 | form.ShowDialog();
369 | }
370 |
371 | private void DeviceTypeMenuItem_Click(object sender, EventArgs e)
372 | {
373 | ToolStripMenuItem item = (ToolStripMenuItem)sender;
374 | CurrentBord = (Board)item.Tag;
375 | updateStatus();
376 | }
377 |
378 | // D&D
379 | private void MainForm_DragEnter(object sender, DragEventArgs e)
380 | {
381 | if (AutoLoaderTimer.Enabled)
382 | {
383 | return;
384 | }
385 | e.Effect = DragDropEffects.Copy;
386 | }
387 |
388 | private void textBox_TargetCode_DragDrop(object sender, DragEventArgs e)
389 | {
390 | if (AutoLoaderTimer.Enabled)
391 | {
392 | return;
393 | }
394 | foreach (string fname in (string[])e.Data.GetData(DataFormats.FileDrop))
395 | {
396 | string ext = System.IO.Path.GetExtension(fname);
397 | ext.ToLower();
398 | if (ext == ".hex")
399 | {
400 | textBox_TargetCode.Text = fname;
401 | checkBox1.Checked = true;
402 | break;
403 | }
404 | }
405 | }
406 |
407 | private void textBox_UploadFile_DragDrop(object sender, DragEventArgs e)
408 | {
409 | if (AutoLoaderTimer.Enabled)
410 | {
411 | return;
412 | }
413 | foreach (string fname in (string[])e.Data.GetData(DataFormats.FileDrop))
414 | {
415 | textBox_UploadFile.Text = fname;
416 | checkBox2.Checked = true;
417 | break;
418 | }
419 | }
420 |
421 | private void textBox1_DragDrop(object sender, DragEventArgs e)
422 | {
423 | if (AutoLoaderTimer.Enabled)
424 | {
425 | return;
426 | }
427 | textBox_UploadFile_DragDrop(sender, e);
428 | button3_Click(null, null);
429 | }
430 |
431 | // store&restore registry
432 | private void storeRegistry()
433 | {
434 | Microsoft.Win32.RegistryKey regkey;
435 | regkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(Resources.Strings.RegKey_RootDir);
436 | regkey.SetValue(Resources.Strings.RegKey_TargetAddress, Decimal.ToInt32(numericUpDown1.Value),Microsoft.Win32.RegistryValueKind.DWord);
437 | if (CurrentBord != null)
438 | {
439 | regkey.SetValue(Resources.Strings.RegKey_BoardName, CurrentBord.Name, Microsoft.Win32.RegistryValueKind.String);
440 | }
441 | }
442 |
443 | private void restoreRegistry()
444 | {
445 | Microsoft.Win32.RegistryKey regkey;
446 | regkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Resources.Strings.RegKey_RootDir);
447 | if (regkey != null)
448 | {
449 | if (regkey.GetValue(Resources.Strings.RegKey_TargetAddress, null) != null)
450 | numericUpDown1.Value = new Decimal((int)regkey.GetValue(Resources.Strings.RegKey_TargetAddress));
451 | if (regkey.GetValue(Resources.Strings.RegKey_BoardName, null) != null)
452 | {
453 | string str = (string)regkey.GetValue(Resources.Strings.RegKey_BoardName);
454 | foreach (Board board in BoardList)
455 | {
456 | if (str == board.Name)
457 | {
458 | CurrentBord = board;
459 | break;
460 | }
461 | }
462 | }
463 | }
464 | }
465 |
466 | // loading board list
467 | public void LoadBoardList()
468 | {
469 | //
470 | System.IO.StreamReader sr;
471 |
472 | if (System.IO.File.Exists("boards.xml"))
473 | {
474 | sr = new System.IO.StreamReader("boards.xml");
475 | }
476 | else
477 | {
478 | System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
479 | sr = new System.IO.StreamReader(
480 | asm.GetManifestResourceStream("ArduinoFileUploader.Resources.boards.xml")
481 | );
482 | }
483 | System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sr.BaseStream);
484 |
485 | string lasttext = null;
486 | Board lastboard = null;
487 | while (reader.Read())
488 | {
489 | switch (reader.NodeType)
490 | {
491 | case System.Xml.XmlNodeType.Element:
492 | if (reader.Name == "board")
493 | {
494 | lastboard = new Board();
495 | }
496 | lasttext = null;
497 | break;
498 | case System.Xml.XmlNodeType.Text:
499 | lasttext = reader.Value;
500 | break;
501 | case System.Xml.XmlNodeType.EndElement:
502 | if (reader.Name == "name")
503 | {
504 | lastboard.Name = lasttext;
505 | }
506 | else if (reader.Name == "bootloader_address")
507 | {
508 | lastboard.BootLoaderAddress = int.Parse(lasttext);
509 | }
510 | else if (reader.Name == "upload_speed")
511 | {
512 | lastboard.UpLoadSpeed = int.Parse(lasttext);
513 | }
514 | else if (reader.Name == "dtr_control")
515 | {
516 | if (lasttext == "Enable1000mSecAndDisable")
517 | {
518 | lastboard.DTRControl = Board.DTRControlTypeEnum.Enable1000mSecAndDisable;
519 | }
520 | else if (lasttext == "EnableAndThrough")
521 | {
522 | lastboard.DTRControl = Board.DTRControlTypeEnum.EnableAndThrough;
523 | }
524 | else
525 | { // perse error
526 | lastboard.DTRControl = Board.DTRControlTypeEnum.Unknown;
527 | }
528 | }
529 | else if (reader.Name == "software_major_version")
530 | {
531 | lastboard.SoftwareMajorVersion = byte.Parse(lasttext);
532 | }
533 | else if (reader.Name == "software_minor_version")
534 | {
535 | lastboard.SoftwareMinorVersion = byte.Parse(lasttext);
536 | }
537 | else if (reader.Name == "board")
538 | {
539 | BoardList.Add(lastboard);
540 | }
541 | else
542 | {
543 | // perse error
544 | }
545 | break;
546 | }
547 |
548 | }
549 | }
550 | }
551 | }
552 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/MainForm.en.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | 88, 12
123 |
124 |
125 | Recive Baud(&R):
126 |
127 |
128 | 95, 16
129 |
130 |
131 | Serial Monitor
132 |
133 |
134 | 55, 16
135 |
136 |
137 | Verify
138 |
139 |
140 | 102, 12
141 |
142 |
143 | Target Address(&A):
144 |
145 |
146 | 76, 12
147 |
148 |
149 | Serial Port(&S):
150 |
151 |
152 | Upload(&U)
153 |
154 |
155 | 59, 16
156 |
157 |
158 | Upload
159 |
160 |
161 | 59, 16
162 |
163 |
164 | Upload
165 |
166 |
167 | 76, 12
168 |
169 |
170 | Upload File(&I):
171 |
172 |
173 | 114, 12
174 |
175 |
176 | Program HEX File(&C):
177 |
178 |
179 | Select File(&F)
180 |
181 |
182 | Select File(&H)
183 |
184 |
185 | 116, 22
186 |
187 |
188 | Exit(&X)
189 |
190 |
191 | 57, 22
192 |
193 |
194 | File(&F)
195 |
196 |
197 | 200, 22
198 |
199 |
200 | Rescan Serial Port(&R)
201 |
202 |
203 | 197, 6
204 |
205 |
206 | 200, 22
207 |
208 |
209 | Bord(&B)
210 |
211 |
212 | 200, 22
213 |
214 |
215 | Reset Target(&T)
216 |
217 |
218 | 200, 22
219 |
220 |
221 | Exit Serial Monitor(&E)
222 |
223 |
224 | 197, 6
225 |
226 |
227 | 200, 22
228 |
229 |
230 | Auto Load Setting(&S)
231 |
232 |
233 | 200, 22
234 |
235 |
236 | Auto Load(&A)
237 |
238 |
239 | 62, 22
240 |
241 |
242 | Tool(&T)
243 |
244 |
245 | 210, 22
246 |
247 |
248 | About This Program(&A)
249 |
250 |
251 | 65, 22
252 |
253 |
254 | Help(&H)
255 |
256 |
--------------------------------------------------------------------------------
/FileUploader/src/Forms/MainForm.ja.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | 509, 19
123 |
124 |
--------------------------------------------------------------------------------
/FileUploader/src/IntelHEX.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ArduinoFileUploader
7 | {
8 | public class IntelHEX
9 | {
10 | public int StartAddress;
11 | public byte[] Data;
12 | List RecordList=new List();
13 | public IntelHEX(string path)
14 | {
15 | Load(path);
16 | }
17 | public IntelHEX()
18 | {
19 | }
20 | public int Load(string path)
21 | {
22 | if(!System.IO.File.Exists(path))return 0;
23 | // 最初の読み込みで先頭アドレスとサイズを確定する
24 | System.IO.StreamReader sr = new System.IO.StreamReader(path);
25 | char[] tokenbuf=new char[16];
26 | int cpos,datalength,offset_h,offset_l,command;
27 | while (sr.Peek() > 0)
28 | {
29 | string linestr = sr.ReadLine();
30 | cpos=0;
31 | linestr.CopyTo(cpos, tokenbuf, 0, 1);cpos+=1;
32 | if (tokenbuf[0] != ':') continue;
33 | datalength = Convert.ToInt32(linestr.Substring(cpos,2), 16); cpos += 2;
34 | offset_h = Convert.ToInt32(linestr.Substring(cpos, 2), 16); cpos += 2;
35 | offset_l = Convert.ToInt32(linestr.Substring(cpos, 2), 16); cpos += 2;
36 | command = Convert.ToInt32(linestr.Substring(cpos, 2), 16); cpos += 2;
37 | switch (command)
38 | {
39 | case 0://Data
40 | byte[] localdata = new byte[datalength];
41 | for (int i = 0; i < datalength; i++)
42 | {
43 | localdata[i] = Convert.ToByte(linestr.Substring(cpos, 2), 16); cpos += 2;
44 | }
45 | DataRecord record = new DataRecord((offset_h << 8) | offset_l, datalength, localdata);
46 | RecordList.Add(record);
47 | break;
48 | case 1://End
49 | case 2://SegmentAddress
50 | case 3://StartSegmentAddress
51 | case 4://ExtLinearAddressCode
52 | case 5://StartLinearAddress
53 | break;
54 | }
55 |
56 | }
57 | sr.Close();
58 | MargeRecord();
59 | return Data.Length;
60 | }
61 | void MargeRecord()
62 | {
63 | int min = int.MaxValue;
64 | int max = -int.MaxValue;
65 | foreach (DataRecord record in RecordList)
66 | {
67 | if (min > record.Address)
68 | {
69 | min = record.Address;
70 | }
71 | if (max < record.Address + record.Length)
72 | {
73 | max = record.Address + record.Length;
74 | }
75 | }
76 | StartAddress = min;
77 | Data = new byte[max - min];
78 | foreach (DataRecord record in RecordList)
79 | {
80 | Array.Copy(record.Data, 0, Data, record.Address - StartAddress, record.Length);
81 | }
82 | }
83 |
84 | class DataRecord
85 | {
86 | public int Address;
87 | public int Length;
88 | public byte[] Data;
89 | public DataRecord(int addr, int len, byte[] data)
90 | {
91 | Address = addr;
92 | Length = len;
93 | Data = data;
94 | }
95 | }
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/FileUploader/src/License.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2010 www.ooishoo.org
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/FileUploader/src/MDXTinyParser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ArduinoFileUploader
7 | {
8 | public class MDXTinyParser
9 | {
10 | byte[] FileImage;
11 | public MDXTinyParser(byte[] image)
12 | {
13 | FileImage = image;
14 | }
15 | public string GetTitle()
16 | {
17 | byte[] strstr = new byte[FileImage.Length+1];
18 | int strindex = 0;
19 | foreach (byte b in FileImage)
20 | {
21 | if (b == 0xd || b==0xa || b==0x1a || b ==0x00 )
22 | {
23 | strstr[strindex] = 0x0;
24 | break;
25 | }
26 | strstr[strindex++] = b;
27 | }
28 | return System.Text.Encoding.GetEncoding(932).GetString(strstr);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/FileUploader/src/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace ArduinoFileUploader
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// アプリケーションのメイン エントリ ポイントです。
12 | ///
13 | [STAThread]
14 | static void Main(string[] args)
15 | {
16 | if (args.Length > 0 && args[0] != null)
17 | {
18 | System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(args[0]);
19 | System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(args[0]);
20 | }
21 | if (System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName != "ja" && System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName != "en")
22 | {
23 | System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
24 | System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
25 | }
26 | Application.EnableVisualStyles();
27 | Application.SetCompatibleTextRenderingDefault(false);
28 | Application.Run(new MainForm());
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/FileUploader/src/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MDXimageTransfer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MDXimageTransfer")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("b307082e-336a-4c4d-80fc-85ac040295fc")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/FileUploader/src/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ArduinoFileUploader.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
17 | ///
18 | // このクラスは StronglyTypedResourceBuilder クラスが ResGen
19 | // または Visual Studio のようなツールを使用して自動生成されました。
20 | // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
21 | // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ArduinoFileUploader.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、
51 | /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/FileUploader/src/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/FileUploader/src/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ArduinoFileUploader.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FileUploader/src/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FileUploader/src/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/FileUploader/src/Readme.txt:
--------------------------------------------------------------------------------
1 | This software is released under the MIT License, see Licence.txt.
--------------------------------------------------------------------------------
/FileUploader/src/Resources/Strings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ArduinoFileUploader.Resources {
12 | using System;
13 |
14 |
15 | ///
16 | /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
17 | ///
18 | // このクラスは StronglyTypedResourceBuilder クラスが ResGen
19 | // または Visual Studio のようなツールを使用して自動生成されました。
20 | // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
21 | // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Strings {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Strings() {
33 | }
34 |
35 | ///
36 | /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ArduinoFileUploader.Resources.Strings", typeof(Strings).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、
51 | /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Breaks an error occurred while auto loading. に類似しているローカライズされた文字列を検索します。
65 | ///
66 | internal static string ErrorMessage_AutoLoad {
67 | get {
68 | return ResourceManager.GetString("ErrorMessage_AutoLoad", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Not specified target board. に類似しているローカライズされた文字列を検索します。
74 | ///
75 | internal static string ErrorMessage_BordNotSpecified {
76 | get {
77 | return ResourceManager.GetString("ErrorMessage_BordNotSpecified", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// HEX file exceeds the load address. に類似しているローカライズされた文字列を検索します。
83 | ///
84 | internal static string ErrorMessage_CodeTooLarge {
85 | get {
86 | return ResourceManager.GetString("ErrorMessage_CodeTooLarge", resourceCulture);
87 | }
88 | }
89 |
90 | ///
91 | /// Send data does not exist. に類似しているローカライズされた文字列を検索します。
92 | ///
93 | internal static string ErrorMessage_DataNotExist {
94 | get {
95 | return ResourceManager.GetString("ErrorMessage_DataNotExist", resourceCulture);
96 | }
97 | }
98 |
99 | ///
100 | /// Directory not found. に類似しているローカライズされた文字列を検索します。
101 | ///
102 | internal static string ErrorMessage_DirectoryNotFound {
103 | get {
104 | return ResourceManager.GetString("ErrorMessage_DirectoryNotFound", resourceCulture);
105 | }
106 | }
107 |
108 | ///
109 | /// Running Worker Thread. に類似しているローカライズされた文字列を検索します。
110 | ///
111 | internal static string ErrorMessage_RunningWorkerThread {
112 | get {
113 | return ResourceManager.GetString("ErrorMessage_RunningWorkerThread", resourceCulture);
114 | }
115 | }
116 |
117 | ///
118 | /// Upload file is too large. に類似しているローカライズされた文字列を検索します。
119 | ///
120 | internal static string ErrorMessage_UploadTooLarge {
121 | get {
122 | return ResourceManager.GetString("ErrorMessage_UploadTooLarge", resourceCulture);
123 | }
124 | }
125 |
126 | ///
127 | /// www.ooishoo.org に類似しているローカライズされた文字列を検索します。
128 | ///
129 | internal static string HomePage {
130 | get {
131 | return ResourceManager.GetString("HomePage", resourceCulture);
132 | }
133 | }
134 |
135 | ///
136 | /// BoardName に類似しているローカライズされた文字列を検索します。
137 | ///
138 | internal static string RegKey_BoardName {
139 | get {
140 | return ResourceManager.GetString("RegKey_BoardName", resourceCulture);
141 | }
142 | }
143 |
144 | ///
145 | /// Software\ArduinoFileUploader に類似しているローカライズされた文字列を検索します。
146 | ///
147 | internal static string RegKey_RootDir {
148 | get {
149 | return ResourceManager.GetString("RegKey_RootDir", resourceCulture);
150 | }
151 | }
152 |
153 | ///
154 | /// TargetAddress に類似しているローカライズされた文字列を検索します。
155 | ///
156 | internal static string RegKey_TargetAddress {
157 | get {
158 | return ResourceManager.GetString("RegKey_TargetAddress", resourceCulture);
159 | }
160 | }
161 |
162 | ///
163 | /// Version 0.22a に類似しているローカライズされた文字列を検索します。
164 | ///
165 | internal static string Version {
166 | get {
167 | return ResourceManager.GetString("Version", resourceCulture);
168 | }
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/FileUploader/src/Resources/Strings.en.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Breaks an error occurred while auto loading.
122 |
123 |
124 | Not specified target board.
125 |
126 |
127 | HEX file exceeds the load address.
128 |
129 |
130 | Send data does not exist.
131 |
132 |
133 | Directory not found.
134 |
135 |
136 | Running Worker Thread.
137 |
138 |
139 | Upload file is too large.
140 |
141 |
--------------------------------------------------------------------------------
/FileUploader/src/Resources/Strings.ja.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | オートロード中にエラーが発生したので中断します
122 |
123 |
124 | ターゲットボードが指定されていません
125 |
126 |
127 | HEXファイルがロードアドレスを超過しています
128 |
129 |
130 | 送るデータがありません
131 |
132 |
133 | 指定されたディレクトリが存在しません
134 |
135 |
136 | ワーカースレッドが稼働中です
137 |
138 |
139 | アップロードファイルが大きすぎます
140 |
141 |
--------------------------------------------------------------------------------
/FileUploader/src/Resources/Strings.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Breaks an error occurred while auto loading.
122 |
123 |
124 | Not specified target board.
125 |
126 |
127 | HEX file exceeds the load address.
128 |
129 |
130 | Send data does not exist.
131 |
132 |
133 | Directory not found.
134 |
135 |
136 | Running Worker Thread.
137 |
138 |
139 | Upload file is too large.
140 |
141 |
142 | www.ooishoo.org
143 |
144 |
145 | BoardName
146 |
147 |
148 | Software\ArduinoFileUploader
149 |
150 |
151 | TargetAddress
152 |
153 |
154 | Version 0.22a
155 |
156 |
--------------------------------------------------------------------------------
/FileUploader/src/Resources/boards.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Arduino Uno(Optiboot V3)
5 | 32256
6 | 115200
7 | EnableAndThrough
8 | 3
9 | 0
10 |
11 |
12 | Arduino Uno(Optiboot V4-V7)
13 | 32256
14 | 115200
15 | EnableAndThrough
16 | 7
17 | 0
18 |
19 |
20 | Arduino Duemilanove
21 | 30720
22 | 57600
23 | Enable1000mSecAndDisable
24 | 1
25 | 16
26 |
27 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/Common.h:
--------------------------------------------------------------------------------
1 | #if !defined( YM_COMMON_H_INCLUDED )
2 | #define YM_COMMON_H_INCLUDED
3 | #include "YM2151.h"
4 | #include "io.h"
5 |
6 | #define _DEBUG
7 |
8 | #ifdef _DEBUG
9 | #define ASSERT(msg) io.Assert(msg)
10 | #define PRINTH(msg,data) io.PrintWord(msg,data)
11 | #else
12 | #define ASSERT(msg)
13 | #define PRINTH(msg,data)
14 | #endif
15 |
16 | #endif //YM_COMMON_H_INCLUDED
17 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/IO.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "Common.h"
5 | #include "IO.h"
6 |
7 | //#define DIRECT_IO
8 |
9 |
10 | IO::IO()
11 | {
12 | }
13 |
14 | void IO::Init()
15 | {
16 | Serial.begin(9600);
17 | return;
18 | }
19 |
20 |
21 | #ifdef _DEBUG
22 | void IO::Assert(char *msg){
23 | Serial.println("**ASSERT**");
24 | Serial.println(msg);
25 | while(1){};
26 | }
27 | void IO::PrintByte(char *msg,uint8_t data){
28 | Serial.print(msg);
29 | Serial.println(data,HEX);
30 | }
31 | void IO::PrintWord(char *msg,uint16_t data){
32 | Serial.print(msg);
33 | Serial.println(data,HEX);
34 | }
35 | void IO::PrintLong(char *msg,uint32_t data){
36 | Serial.print(msg);
37 | Serial.println(data,HEX);
38 | }
39 | #endif
40 |
41 |
42 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/IO.h:
--------------------------------------------------------------------------------
1 | #if !defined( YM_IO_H_INCLUDED )
2 | #define YM_IO_H_INCLUDED
3 | #include "arduino.h"
4 | #include
5 |
6 | //#define BORD_10
7 | #define BORD_11
8 |
9 | class IO{
10 | public:
11 | IO();
12 | void Init();
13 | void Assert(char *msg);
14 | void PrintByte(char *msg,uint8_t data);
15 | void PrintWord(char *msg,uint16_t data);
16 | void PrintLong(char *msg,uint32_t data);
17 | private:
18 | };
19 | extern IO io;
20 | #endif //YM_IO_H_INCLUDED
21 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/License.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2010 www.ooishoo.org
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/MDXParser.cpp:
--------------------------------------------------------------------------------
1 | #include "Common.h"
2 | #include "MDXParser.h"
3 |
4 | void MDXParser::Setup(uint16_t bp)
5 | {
6 | uint16_t tableaddr=0;
7 | DataBP = bp;
8 | SetTempo(100);
9 | while(ReadData8(tableaddr++)!=0);
10 | BaseOffset = tableaddr;
11 | TimbreOffset = ReadData16(tableaddr);
12 | tableaddr+=2;
13 | for(int i=0;i 0){
31 | OPMChannel[i].KeyOnDelayClock -= c;
32 | if(OPMChannel[i].KeyOnDelayClock==0){
33 | OPMChannel[i].KeyOn();
34 | }
35 | }
36 | OPMChannel[i].Calc();
37 | if(OPMChannel[i].KeyOffClock > 0){
38 | OPMChannel[i].KeyOffClock -= c;
39 | if(OPMChannel[i].KeyOffClock==0){
40 | OPMChannel[i].KeyOff();
41 | }
42 | }
43 | while(OPMChannel[i].Clock==0){
44 | OPMChannel[i].Elapse();
45 | if(OPMChannel[i].StatusF & (FLG_HALT | FLG_SYNCWAIT | FLG_SYNCWAITRUN))break;
46 | }
47 | }
48 | for(int i=0;i 0 && OPMChannel[i].KeyOffClock < minclock)minclock = OPMChannel[i].KeyOffClock;
53 | }
54 | return minclock;
55 | }
56 | void MDXParser::SetTempo(uint8_t tempo){
57 | Tempo = tempo;
58 | ClockMicro = (1024*(256-Tempo))/4;
59 | }
60 | void MDXParser::SendSyncRelease(uint8_t ch){
61 | if(ch < ChNum){
62 | OPMChannel[ch].StatusF &= ~FLG_SYNCWAIT;
63 | while(OPMChannel[ch].Clock==0){
64 | OPMChannel[ch].Elapse();
65 | }
66 | OPMChannel[ch].StatusF |= FLG_SYNCWAITRUN;
67 | }
68 | }
69 | uint16_t MDXParser::GetTimbreAddr(uint8_t timbleno){
70 |
71 | for(int i=0;i<256;i++){
72 | uint16_t addr = BaseOffset + TimbreOffset + 27 * (uint16_t)i;
73 | uint8_t tno = ReadData8(addr);
74 | if(tno == timbleno) return addr;
75 | }
76 | ASSERT("can not find timbre");
77 | return 0;
78 | }
79 | uint32_t MDXParser::ClockToMilliSec(uint8_t clock){
80 | return ((uint32_t)clock * ClockMicro)/(uint32_t)1000;
81 | }
82 | uint32_t MDXParser::ClockToMicroSec(uint8_t clock){
83 | return ((uint32_t)clock * ClockMicro);
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/MDXParser.h:
--------------------------------------------------------------------------------
1 | #if !defined( YM_MDXP_H_INCLUDED )
2 | #define YM_MDXP_H_INCLUDED
3 | #include "arduino.h"
4 | #include "MMLParser.h"
5 | class MDXParser{
6 | public:
7 | static const uint8_t ChNum=8;
8 |
9 | uint16_t DataBP;
10 | uint16_t BaseOffset;
11 | uint16_t TimbreOffset;
12 | uint8_t Tempo;
13 | uint32_t ClockMicro;
14 | MMLParser OPMChannel[ChNum];
15 | void Setup(uint16_t);
16 | uint16_t Elapse(uint16_t);
17 | uint16_t Forward(uint16_t);
18 | void SetTempo(uint8_t);
19 | uint16_t GetTimbreAddr(uint8_t);
20 | void SendSyncRelease(uint8_t);
21 | uint32_t ClockToMilliSec(uint8_t clock);
22 | uint32_t ClockToMicroSec(uint8_t clock);
23 |
24 | inline uint8_t ReadData8(uint16_t addr){
25 | return (uint8_t)(pgm_read_byte_near(DataBP + (addr)));
26 | }
27 |
28 | inline uint16_t ReadData16(uint16_t addr){
29 | uint16_t rdata = pgm_read_word_near(DataBP + (addr));
30 | return (rdata << 8) | (rdata >> 8);
31 | }
32 |
33 |
34 | };
35 | extern MDXParser mdx;
36 | #endif //YM_MDXP_H_INCLUDED
37 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/MMLParser.cpp:
--------------------------------------------------------------------------------
1 | #include "Common.h"
2 | #include "MMLParser.h"
3 | #include "MDXParser.h"
4 |
5 | // ※クロックの1単位は全音符/192
6 | typedef void (MMLParser::*CommandFunc)();
7 | static const CommandFunc CommandFuncTable[]={
8 | &MMLParser::C_xx_Unknown,
9 | &MMLParser::C_xx_Unknown,
10 | &MMLParser::C_xx_Unknown,
11 | &MMLParser::C_xx_Unknown,
12 | &MMLParser::C_xx_Unknown,
13 | &MMLParser::C_xx_Unknown,
14 | &MMLParser::C_xx_Unknown,
15 | &MMLParser::C_e7_Fadeout,
16 | &MMLParser::C_e8_PCM8Ext,
17 | &MMLParser::C_e9_LFODelay,
18 | &MMLParser::C_ea_LFOCtrl,
19 | &MMLParser::C_eb_LFOVolumeCtrl,
20 | &MMLParser::C_ec_LFOPitchCtrl,
21 | &MMLParser::C_ed_NoisePitch,
22 | &MMLParser::C_ee_SyncWait,
23 | &MMLParser::C_ef_SyncSend,
24 | &MMLParser::C_f0_KeyOnDelay,
25 | &MMLParser::C_f1_EndOfData,
26 | &MMLParser::C_f2_Portamento,
27 | &MMLParser::C_f3_Detune,
28 | &MMLParser::C_f4_ExitRepeat,
29 | &MMLParser::C_f5_BottomRepeat,
30 | &MMLParser::C_f6_StartRepeat,
31 | &MMLParser::C_f7_DisableKeyOn,
32 | &MMLParser::C_f8_KeyOnTime,
33 | &MMLParser::C_f9_VolumeUp,
34 | &MMLParser::C_fa_VolumeDown,
35 | &MMLParser::C_fb_Volume,
36 | &MMLParser::C_fc_Panpot,
37 | &MMLParser::C_fd_Timbre,
38 | &MMLParser::C_fe_Registar,
39 | &MMLParser::C_ff_Tempo,
40 | };
41 |
42 | void MMLParser::Init(uint8_t ch,uint16_t base,uint16_t mmloffset){
43 | StatusF = 0;
44 | FunctionF = 0;
45 | CurrentAddr = base + mmloffset;
46 | Channel = ch;
47 | RegPAN = 0x3;
48 | KeyLength = 64;
49 | Volume = 0xf;
50 | VLFO.Offset = 0;
51 | PLFO.Offset = 0;
52 | Portamento = 0;
53 | for(int i=0;i> 6)); //
72 | KeyOff(); //
73 | if(StatusF & FLG_NEXTNKEYOFF){
74 | StatusF |= FLG_NKEYOFF;
75 | StatusF &= ~FLG_NEXTNKEYOFF;
76 | } else {
77 | StatusF &= ~FLG_NKEYOFF;
78 | }
79 | if(KeyOnDelay==0){
80 | KeyOn();
81 | } else {
82 | KeyOnDelayClock = KeyOnDelay;
83 | }
84 | return;
85 | }
86 | (this->*(CommandFuncTable[command-0xe0]))();
87 | }
88 |
89 | void MMLParser::Calc(){
90 | if(FunctionF & FLG_FOUT){
91 | }
92 | if(FunctionF & FLG_VLFO){
93 | uint16_t Delta;
94 | switch(VLFO.Type){
95 | case 0: // non op
96 | break;
97 | case 1: // L001120
98 | VLFO.Offset += VLFO.Delta;
99 | if(--VLFO.LengthCounter == 0){
100 | VLFO.LengthCounter = VLFO.Length;
101 | VLFO.Offset = VLFO.DeltaFixd;
102 | }
103 | break;
104 | case 2: // L001138
105 | if(--VLFO.LengthCounter == 0){
106 | VLFO.LengthCounter = VLFO.Length;
107 | VLFO.Offset += VLFO.Delta;
108 | VLFO.Delta = -VLFO.Delta;
109 | }
110 | break;
111 | case 3: // L00114e
112 | VLFO.Offset += VLFO.Delta;
113 | if(--VLFO.LengthCounter == 0){
114 | VLFO.LengthCounter = VLFO.Length;
115 | VLFO.Delta = -VLFO.Delta;
116 | }
117 | break;
118 | case 4: // L001164
119 | if(--VLFO.LengthCounter == 0){
120 | VLFO.LengthCounter = VLFO.Length;
121 | VLFO.Offset = VLFO.Delta * random(255);
122 | }
123 | break;
124 | default:
125 | ASSERT("Unknown VLFO type!");
126 | break;
127 | }
128 | UpdateVolume();
129 | }
130 | if(FunctionF & FLG_PLFO){
131 | uint16_t Delta;
132 | switch(PLFO.Type){
133 | case 0: // non op
134 | break;
135 | case 1: // L0010be
136 | PLFO.Offset += PLFO.Delta;
137 | if(--PLFO.LengthCounter == 0){
138 | PLFO.LengthCounter = PLFO.Length;
139 | PLFO.Offset = -PLFO.Offset;
140 | }
141 | break;
142 | case 2: // L0010d4
143 | PLFO.Offset = PLFO.Delta;
144 | if(--PLFO.LengthCounter == 0){
145 | PLFO.LengthCounter = PLFO.Length;
146 | PLFO.Delta = -PLFO.Delta;
147 | }
148 | break;
149 | case 3: // L0010ea
150 | PLFO.Offset += PLFO.Delta;
151 | if(--PLFO.LengthCounter == 0){
152 | PLFO.LengthCounter = PLFO.Length;
153 | PLFO.Delta = -PLFO.Delta;
154 | }
155 | break;
156 | case 4: // L001100
157 | if(--PLFO.LengthCounter == 0){
158 | PLFO.LengthCounter = PLFO.Length;
159 | PLFO.Offset = PLFO.Delta * random(255);
160 | }
161 | break;
162 | default:
163 | ASSERT("Unknown PLFO type!");
164 | break;
165 |
166 | }
167 | }
168 | if((FunctionF & FLG_MPT) || (FunctionF & FLG_PLFO)){
169 | if(FunctionF & FLG_MPT){
170 | Portamento += PortamentoDelta;
171 | }
172 | SetTone();
173 | }
174 |
175 | }
176 |
177 | void MMLParser::KeyOn(){
178 | Portamento = 0;
179 | SetTone();
180 | YM2151.noteOn(Channel);
181 | //YM2151.write(0x08,(RegSLOTMASK << 3) + Channel);
182 | FunctionF &= ~(FLG_MPT | FLG_FOUT);
183 | if(FunctionF & FLG_NEXTMPT){
184 | FunctionF |= FLG_MPT;
185 | }
186 | if(FunctionF & FLG_NEXTFOUT){
187 | FunctionF |= FLG_FOUT;
188 | }
189 | FunctionF &= ~(FLG_NEXTMPT | FLG_NEXTFOUT);
190 | }
191 |
192 | void MMLParser::KeyOff(){
193 | if((StatusF & FLG_NKEYOFF) == 0){
194 | YM2151.write(0x08,0x00 + Channel);
195 | } else {
196 | StatusF &= ~FLG_NKEYOFF;
197 | }
198 | KeyOffClock = 0;
199 | }
200 |
201 | void MMLParser::SetTone(){
202 | int16_t offset;
203 | offset = Detune;
204 | if(FunctionF & FLG_MPT){
205 | offset += Portamento>>16; // 右シフトは問題なし
206 | }
207 | if(FunctionF & FLG_PLFO){
208 | offset += PLFO.Offset>>16;
209 | }
210 | YM2151.setTone(Channel,Note,offset);
211 | return;
212 | }
213 |
214 | void MMLParser::UpdateVolume(){
215 | YM2151.setVolume(Channel,Volume,VLFO.Offset);
216 | }
217 |
218 | //・未定義コマンド
219 | void MMLParser::C_xx_Unknown(){
220 | ASSERT("Unknown MML Command.");
221 | StatusF |= FLG_HALT;
222 | }
223 | //・フェードアウト
224 | // [$E7] + [$01] + [SPEED] $FOコマンド対応
225 | void MMLParser::C_e7_Fadeout(){
226 | mdx.ReadData8(CurrentAddr++);
227 | mdx.ReadData8(CurrentAddr++);
228 | }
229 | //・PCM8拡張モード移行
230 | // [$E8] Achの頭で有効
231 | void MMLParser::C_e8_PCM8Ext(){
232 | }
233 | //・LFOディレイ設定
234 | // [$E9] + [???] MDコマンド対応
235 | void MMLParser::C_e9_LFODelay(){
236 | mdx.ReadData8(CurrentAddr++);
237 | }
238 | //・OPMLFO制御
239 | // [$EA] + [$80] MHOF
240 | // [$EA] + [$81] MHON
241 | // [$EA] + [SYNC/WAVE] + [LFRQ] + [PMD] + [AMD] + [PMS/AMS]
242 | void MMLParser::C_ea_LFOCtrl(){
243 | uint8_t lfocom = mdx.ReadData8(CurrentAddr++);
244 | if(lfocom & 0x80){
245 | if(lfocom & 0x01){ // ??
246 | YM2151.write(0x38+Channel,RegPMSAMS);
247 | } else {
248 | YM2151.write(0x38+Channel,0);
249 | }
250 | return;
251 | }
252 | YM2151.write(0x1b,lfocom);
253 |
254 | uint8_t lfrq = mdx.ReadData8(CurrentAddr++);
255 | YM2151.write(0x18,lfrq);
256 | uint8_t pmd = mdx.ReadData8(CurrentAddr++);
257 | YM2151.write(0x19,pmd);
258 | uint8_t amd = mdx.ReadData8(CurrentAddr++);
259 | YM2151.write(0x19,amd);
260 | uint8_t RegPMSAMS = mdx.ReadData8(CurrentAddr++);
261 | YM2151.write(0x38+Channel,RegPMSAMS);
262 | }
263 | //・音量LFO制御
264 | // [$EB] + [$80] MAOF
265 | // [$EB] + [$81] MAON
266 | // [$EB] + [WAVE※1] + [周期※2].w + [変移※4].w
267 | void MMLParser::C_eb_LFOVolumeCtrl(){
268 | uint8_t lfocom = mdx.ReadData8(CurrentAddr++);
269 | if(lfocom & 0x80){
270 | if(lfocom & 0x01){
271 | FunctionF |= FLG_VLFO;
272 | } else {
273 | FunctionF &= ~FLG_VLFO;
274 | VLFO.Offset = 0;
275 | }
276 | return;
277 | }
278 | int16_t DeltaFixd;
279 | VLFO.Type = lfocom+1;
280 | VLFO.Length = mdx.ReadData16(CurrentAddr);
281 | CurrentAddr+=2;
282 | DeltaFixd = VLFO.DeltaStart = mdx.ReadData16(CurrentAddr);
283 | CurrentAddr+=2;
284 | if((lfocom & 1)==0){
285 | DeltaFixd *= (int16_t)VLFO.Length;
286 | }
287 | DeltaFixd = -DeltaFixd;
288 | if(DeltaFixd < 0)DeltaFixd = 0;
289 | VLFO.DeltaFixd = DeltaFixd;
290 |
291 | VLFO.LengthCounter = VLFO.Length;
292 | VLFO.Delta = VLFO.DeltaStart;
293 | VLFO.Offset = VLFO.DeltaFixd;
294 |
295 | FunctionF |= FLG_VLFO;
296 | }
297 | //・音程LFO制御
298 | // [$EC] + [$80] MPOF
299 | // [$EC] + [$81] MPON
300 | // [$EC] + [WAVE※1] + [周期※2].w + [変移※3].w
301 | void MMLParser::C_ec_LFOPitchCtrl(){
302 | uint8_t lfocom_f = mdx.ReadData8(CurrentAddr++);
303 | if(lfocom_f & 0x80){
304 | if(lfocom_f & 0x01){
305 | FunctionF |= FLG_PLFO;
306 | } else {
307 | FunctionF &= ~FLG_PLFO;
308 | PLFO.Offset = 0;
309 | }
310 | return;
311 | }
312 | uint8_t lfocom = lfocom_f;
313 | lfocom &= 0x3;
314 | PLFO.Type = lfocom + 1;
315 | lfocom += lfocom;
316 | uint16_t length = PLFO.Length = mdx.ReadData16(CurrentAddr);CurrentAddr+=2;
317 | if(lfocom != 2){
318 | length >>= 1;
319 | if(lfocom == 6){length = 1;}
320 | }
321 | PLFO.LengthFixd = length;
322 | int16_t delta = mdx.ReadData16(CurrentAddr);CurrentAddr+=2;
323 | int16_t delta_l = delta;
324 | if(lfocom_f >= 0x4){
325 | lfocom_f &= 0x3;
326 | } else {
327 | delta_l >>= 8;
328 | }
329 |
330 | PLFO.DeltaStart = delta_l;
331 | if(lfocom_f != 0x2) delta_l = 0;
332 | PLFO.OffsetStart = delta_l;
333 |
334 | PLFO.LengthCounter = PLFO.LengthFixd;
335 | PLFO.Delta = PLFO.DeltaStart;
336 | PLFO.Offset = PLFO.OffsetStart;
337 |
338 | FunctionF |= FLG_PLFO;
339 | }
340 |
341 |
342 |
343 | //・ADPCM/ノイズ周波数設定
344 | // チャンネルH
345 | // [$ED] + [???] ノイズ周波数設定。ビット7はノイズON/OFF
346 | // チャンネルP
347 | // [$ED] + [???] Fコマンド対応
348 | void MMLParser::C_ed_NoisePitch(){
349 | uint8_t noise = mdx.ReadData8(CurrentAddr++);
350 | YM2151.write(0x0f,noise);
351 | }
352 | //・同期信号待機
353 | // [$EE]
354 | void MMLParser::C_ee_SyncWait(){
355 | StatusF |= FLG_SYNCWAIT;
356 | }
357 | //・同期信号送出
358 | // [$EF] + [チャネル番号(0~15)]
359 | void MMLParser::C_ef_SyncSend(){
360 | uint8_t sendch = mdx.ReadData8(CurrentAddr++);
361 | mdx.SendSyncRelease(sendch);
362 | }
363 | //・キーオンディレイ
364 | // [$F0] + [???] kコマンド対応
365 | void MMLParser::C_f0_KeyOnDelay(){
366 | KeyOnDelay = mdx.ReadData8(CurrentAddr++);
367 | }
368 | //・データエンド
369 | // [$F1] + [$00] 演奏終了
370 | // [$F1] + [ループポインタ].w ポインタ位置から再演奏
371 | void MMLParser::C_f1_EndOfData(){
372 | uint8_t off_u = (uint8_t)mdx.ReadData8(CurrentAddr++);
373 | if(off_u==0x0){
374 | StatusF |= FLG_HALT;
375 | KeyOff();
376 | } else {
377 | uint8_t off_l = (uint8_t)mdx.ReadData8(CurrentAddr++);
378 | uint16_t off=(uint16_t)off_u<< 8 | (uint16_t)off_l;
379 | off = (off ^ 0xffff)+1;
380 | CurrentAddr -= off;
381 | }
382 | }
383 | //・ポルタメント
384 | // [$F2] + [変移※3].w _コマンド対応 1単位は(半音/16384)
385 | // ※3 変移 1クロック毎の変化量。単位はデチューンの1/256
386 | void MMLParser::C_f2_Portamento(){
387 | int16_t port = mdx.ReadData16(CurrentAddr);
388 | CurrentAddr+=2;
389 | PortamentoDelta = port;
390 | for(int i=0;i<8;i++){ // =<< 8 だけどArduinoの32bit演算libで挙動不審
391 | PortamentoDelta += PortamentoDelta;
392 | }
393 | Portamento = 0;
394 | FunctionF |= FLG_NEXTMPT;
395 | }
396 | //・デチューン
397 | // [$F3] + [???].w Dコマンド対応 1単位は(半音/64)
398 | void MMLParser::C_f3_Detune(){
399 | int16_t dt = mdx.ReadData16(CurrentAddr);
400 | CurrentAddr+=2;
401 | Detune = dt;
402 | }
403 | //・リピート脱出
404 | // [$F4] + [終端コマンドへのオフセット+1].w
405 | void MMLParser::C_f4_ExitRepeat(){
406 | int16_t off = (int16_t)mdx.ReadData16(CurrentAddr);
407 | CurrentAddr += 2;
408 | int16_t btmaddr = CurrentAddr+off;
409 | int16_t btmoff = (int16_t)mdx.ReadData16(btmaddr);
410 | btmaddr += 2;
411 | btmoff = (btmoff ^ 0xffff)+1;
412 | int16_t tgtaddr = btmaddr-btmoff-1;
413 | uint8_t i;
414 | for(i=0;i= RepeatCnt) ASSERT("Address can not found.");
418 | if(RepeatList[i].Count==1){
419 | // break
420 | CurrentAddr = btmaddr;
421 | RepeatList[i].Addr = 0;
422 | RepeatList[i].Count = 0;
423 | }
424 | }
425 | //・リピート終端
426 | // [$F5] + [開始コマンドへのオフセット+2].w
427 | void MMLParser::C_f5_BottomRepeat(){
428 | int16_t off = (int16_t)mdx.ReadData16(CurrentAddr);
429 | CurrentAddr += 2;
430 | off = (off ^ 0xffff)+1;
431 | int16_t tgtaddr = CurrentAddr-off-1;
432 | uint8_t i;
433 | for(i=0;i= RepeatCnt) ASSERT("Address can not found.");
437 |
438 | RepeatList[i].Count--;
439 | if(RepeatList[i].Count>0){
440 | // repeat
441 | CurrentAddr -= off;
442 | } else {
443 | // exit repeat
444 | RepeatList[i].Addr = 0;
445 | }
446 | }
447 | //・リピート開始
448 | // [$F6] + [リピート回数] + [$00]
449 | void MMLParser::C_f6_StartRepeat(){
450 | uint8_t count = mdx.ReadData8(CurrentAddr);
451 | CurrentAddr+=2;
452 | uint8_t i;
453 | for(i=0;i= RepeatCnt) ASSERT("Repeat list overflow.");
457 | RepeatList[i].Addr = CurrentAddr-1;
458 | RepeatList[i].Count = count;
459 | }
460 | //・キーオフ無効
461 | // [$F7] 次のNOTE発音後キーオフしない
462 | // A6->S0016 |= 0x04;
463 | void MMLParser::C_f7_DisableKeyOn(){
464 | StatusF |= FLG_NEXTNKEYOFF;
465 | }
466 | //・発音長指定
467 | // [$F8] + [$01~$08] qコマンド対応
468 | // [$F8] + [$FF~$80] @qコマンド対応(2の補数)
469 | void MMLParser::C_f8_KeyOnTime(){
470 | // 全音長の÷8にあたる時間が経過した時点でキーオフします。
471 | uint8_t length = mdx.ReadData8(CurrentAddr++);
472 | if(length <= 8){
473 | KeyLength = length * 8;
474 | } else {
475 | KeyLength = length - 0x80; // ??
476 | }
477 | }
478 | //・音量増大
479 | // [$F9] ※vコマンド後では、 v0 → v15 へと変化
480 | // ※@vコマンド後では、@v0 → @v127 へと変化
481 | void MMLParser::C_f9_VolumeUp(){
482 | if(Volume & 0x80){
483 | if(Volume > 0x80)Volume--;
484 | } else {
485 | if(Volume < 15)Volume++;
486 | }
487 | UpdateVolume();
488 | }
489 | //・音量減小
490 | // [$FA] ※vコマンド後では、 v15 → v0 へと変化
491 | // ※@vコマンド後では、@v127 → @v0 へと変化
492 | void MMLParser::C_fa_VolumeDown(){
493 | if(Volume & 0x80){
494 | if(Volume < 0xff)Volume++;
495 | } else {
496 | if(Volume > 0)Volume--;
497 | }
498 | UpdateVolume();
499 | }
500 | //・音量設定
501 | // [$FB] + [$00~$15] vコマンド対応
502 | // [$FB] + [$80~$FF] @vコマンド対応(ビット7無効)
503 | void MMLParser::C_fb_Volume(){
504 | Volume = mdx.ReadData8(CurrentAddr++);
505 | UpdateVolume();
506 | }
507 | //・出力位相設定
508 | // [$FC] + [???] pコマンド対応
509 | void MMLParser::C_fc_Panpot(){
510 | uint8_t pan = mdx.ReadData8(CurrentAddr++);
511 | RegPAN = pan;
512 | YM2151.setPanpot(Channel,RegPAN);
513 | }
514 | //・音色設定
515 | // [$FD] + [???] @コマンド対応
516 | #define DUMP_TIMBRE
517 | void MMLParser::C_fd_Timbre(){
518 | uint8_t tno = mdx.ReadData8(CurrentAddr++);
519 | uint16_t taddr = mdx.GetTimbreAddr(tno);
520 | uint8_t no = mdx.ReadData8(taddr++);
521 | if(no!=tno)ASSERT("TimbreNo Unmuch");
522 | YM2151.loadTimbre(Channel,mdx.GetTimbreAddr(tno) + mdx.DataBP);
523 | YM2151.setPanpot(Channel,RegPAN);
524 | UpdateVolume();
525 | }
526 |
527 | //・OPMレジスタ設定
528 | // [$FE] + [レジスタ番号] + [出力データ]
529 | void MMLParser::C_fe_Registar(){
530 | uint8_t reg = mdx.ReadData8(CurrentAddr++);
531 | uint8_t data = mdx.ReadData8(CurrentAddr++);
532 | YM2151.write(reg,data);
533 | }
534 | //・テンポ設定
535 | // [$FF] + [???] @tコマンド対応
536 | void MMLParser::C_ff_Tempo(){
537 | uint8_t tempo = mdx.ReadData8(CurrentAddr++);
538 | mdx.SetTempo(tempo);
539 | }
540 |
541 |
542 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/MMLParser.h:
--------------------------------------------------------------------------------
1 | #if !defined( YM_MMLP_H_INCLUDED )
2 | #define YM_MMLP_H_INCLUDED
3 | #include "arduino.h"
4 |
5 | #define FLG_HALT (1<<0)
6 | #define FLG_SYNCWAIT (1<<1)
7 | #define FLG_SYNCWAITRUN (1<<2)
8 | #define FLG_NKEYOFF (1<<3)
9 | #define FLG_NEXTNKEYOFF (1<<4)
10 |
11 | #define FLG_NEXTMPT (1<<0) // ポルタメント実行中
12 | #define FLG_NEXTFOUT (1<<1) // ボリュームフェード実行中
13 | #define FLG_MPT (1<<4) // ポルタメント実行中
14 | #define FLG_FOUT (1<<5) // ボリュームフェード実行中
15 | #define FLG_VLFO (1<<6) // ボリュームLFO実行中
16 | #define FLG_PLFO (1<<7) // ピッチLFO実行中
17 |
18 | class MMLParser{
19 | static const uint8_t RepeatCnt=4;
20 | public:
21 | uint8_t StatusF;
22 | uint8_t FunctionF;
23 | uint8_t Channel;
24 | uint16_t MMLOffset;
25 | uint16_t CurrentAddr;
26 | uint8_t Clock;
27 | uint8_t KeyOffClock;
28 |
29 | typedef struct {
30 | uint16_t Addr;
31 | uint8_t Count;
32 | }RepeatFrame;
33 | RepeatFrame RepeatList[4];
34 | int8_t KeyLength;
35 |
36 | uint32_t Portamento;
37 | uint32_t PortamentoDelta;
38 | uint16_t Detune;
39 | uint8_t Note;
40 | uint8_t Volume;
41 | uint8_t KeyOnDelay;
42 | uint8_t KeyOnDelayClock;
43 |
44 | uint8_t RegPAN;
45 | uint8_t RegPMSAMS;
46 |
47 | typedef struct {
48 | uint32_t OffsetStart; //32->16
49 | uint32_t DeltaStart; //32->16
50 | uint32_t Offset; //32->16
51 | uint32_t Delta; //32->16
52 | uint16_t LengthFixd;
53 | uint16_t Length;
54 | uint16_t LengthCounter;
55 | int8_t Type;
56 | }PLFOFrame;
57 | PLFOFrame PLFO;
58 |
59 | typedef struct {
60 | uint16_t DeltaStart;
61 | uint16_t DeltaFixd;
62 | uint16_t Delta;
63 | uint16_t Offset;
64 | uint16_t Length;
65 | uint16_t LengthCounter;
66 | int8_t Type;
67 | }VLFOFrame;
68 | VLFOFrame VLFO;
69 |
70 | void Init(uint8_t,uint16_t,uint16_t);
71 | void Elapse();
72 | void Calc();
73 | void SetTone();
74 | void KeyOn();
75 | void KeyOff();
76 | void UpdateVolume();
77 |
78 | void C_xx_Unknown();
79 | void C_e7_Fadeout();
80 | void C_e8_PCM8Ext();
81 | void C_e9_LFODelay();
82 | void C_ea_LFOCtrl();
83 | void C_eb_LFOVolumeCtrl();
84 | void C_ec_LFOPitchCtrl();
85 | void C_ed_NoisePitch();
86 | void C_ee_SyncWait();
87 | void C_ef_SyncSend();
88 | void C_f0_KeyOnDelay();
89 | void C_f1_EndOfData();
90 | void C_f2_Portamento();
91 | void C_f3_Detune();
92 | void C_f4_ExitRepeat();
93 | void C_f5_BottomRepeat();
94 | void C_f6_StartRepeat();
95 | void C_f7_DisableKeyOn();
96 | void C_f8_KeyOnTime();
97 | void C_f9_VolumeUp();
98 | void C_fa_VolumeDown();
99 | void C_fb_Volume();
100 | void C_fc_Panpot();
101 | void C_fd_Timbre();
102 | void C_fe_Registar();
103 | void C_ff_Tempo();
104 |
105 | };
106 | #endif //YM_MMLP_H_INCLUDED
107 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/Readme.txt:
--------------------------------------------------------------------------------
1 | This software is released under the MIT License, see Licence.txt.
--------------------------------------------------------------------------------
/SketchMDXPlayer/SketchMDXPlayer.pde:
--------------------------------------------------------------------------------
1 | /*
2 | SketchMDXPlayer v0.31
3 | author:ISH
4 | */
5 | #include "YM2151.h"
6 | #include "IO.h"
7 | #include "MMLParser.h"
8 | #include "MDXParser.h"
9 |
10 | IO io;
11 | MDXParser mdx;
12 |
13 | int32_t waittime=0;
14 | uint32_t proctime=0;
15 |
16 | void setup()
17 | {
18 | Serial.begin(9600);
19 | io.Init();
20 | YM2151.begin();
21 | mdx.Setup(0x2800);
22 | mdx.Elapse(0);
23 | }
24 |
25 | void loop()
26 | {
27 | waittime = mdx.ClockToMicroSec(1);
28 | waittime -= proctime;
29 | while(waittime > 0){
30 | if(waittime > 16383){
31 | delayMicroseconds(16383);
32 | waittime -= 16383;
33 | } else {
34 | delayMicroseconds(waittime);
35 | waittime = 0;
36 | }
37 | }
38 | proctime = micros();
39 | mdx.Elapse(1);
40 | proctime = micros() - proctime;
41 | }
42 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/YM2151.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | YM2151 library v0.13
3 | author:ISH
4 | */
5 | #include
6 | #include
7 | #include
8 |
9 | #include "Common.h"
10 | #include "YM2151.h"
11 |
12 | #define DIRECT_IO
13 |
14 | YM2151_Class YM2151;
15 |
16 | YM2151_Class::YM2151_Class()
17 | {
18 | }
19 |
20 | /*! IOの初期設定を行いYM2151/YM3012をハードリセットする、必ず呼ぶ必要あり
21 | */
22 | void YM2151_Class::begin()
23 | {
24 | digitalWrite(PIN_IC, HIGH);
25 | digitalWrite(PIN_ADDR0, HIGH);
26 | digitalWrite(PIN_WR, HIGH);
27 | digitalWrite(PIN_RD, HIGH);
28 |
29 | pinMode(PIN_ADDR0, OUTPUT);
30 | pinMode(PIN_WR, OUTPUT);
31 | pinMode(PIN_RD, OUTPUT);
32 | pinMode(PIN_IC, OUTPUT);
33 | digitalWrite(PIN_IC, LOW);
34 | delay(100);
35 | digitalWrite(PIN_IC, HIGH);
36 | delay(100);
37 | return;
38 | }
39 |
40 | //
41 | #define RD_HIGH (PORTB = PORTB | 0x4)
42 | #define RD_LOW (PORTB = PORTB & ~0x4)
43 | #define WR_HIGH (PORTB = PORTB | 0x8)
44 | #define WR_LOW (PORTB = PORTB & ~0x8)
45 | #define A0_HIGH (PORTB = PORTB | 0x10)
46 | #define A0_LOW (PORTB = PORTB & ~0x10)
47 |
48 | #define BUS_READ DDRD=0x02;DDRB=0x3c;
49 | #define BUS_WRITE DDRD=0xfe;DDRB=0x3f;
50 |
51 | #ifdef DIRECT_IO
52 |
53 | static uint8_t last_write_addr=0x00;
54 |
55 | /*! 指定アドレスのレジスタに書き込みを行う
56 | \param addr アドレス
57 | \param data データ
58 | */
59 | void YM2151_Class::write(uint8_t addr,uint8_t data)
60 | {
61 | uint8_t i,wi;
62 | volatile uint8_t *ddrD=&DDRD;
63 | volatile uint8_t *ddrB=&DDRB;
64 | volatile uint8_t *portD=&PORTD;
65 | volatile uint8_t *portB=&PORTB;
66 |
67 | if(last_write_addr != 0x20){
68 | // addr 0x20へのアクセスの後busyフラグが落ちなくなる病 '86の石だと発生
69 | // 他のレジスタに書くまで落ちないので、強引だが0x20アクセス後ならチェックしない
70 | *ddrD &= ~(_BV(2) | _BV(3) | _BV(4) | _BV(5) | _BV(6) | _BV(7));
71 | *ddrB &= ~(_BV(0) | _BV(1));
72 | wait(8);
73 | A0_LOW;
74 | wait(4);
75 | for(i=0;i<32;i++){
76 | RD_LOW;
77 | wait(4);
78 | if((*portB & _BV(1))==0){ // Read Status
79 | RD_HIGH;
80 | wait(4);
81 | break;
82 | }
83 | RD_HIGH;
84 | wait(8);
85 | if(i>16){
86 | delayMicroseconds(1);
87 | }
88 | }
89 | }
90 | wait(4);
91 |
92 | *ddrD |= (_BV(2) | _BV(3) | _BV(4) | _BV(5) | _BV(6) | _BV(7));
93 | *ddrB |= (_BV(0) | _BV(1));
94 | wait(8);
95 | A0_LOW;
96 | *portD = (addr << 2) | (*portD & 0x03);
97 | *portB = (addr >> 6) | (*portB & 0xfc);
98 | wait(4);
99 | WR_LOW; // Write Address
100 | wait(4);
101 | WR_HIGH;
102 | wait(2);
103 | A0_HIGH;
104 | wait(2);
105 | *portD = (data << 2) | (*portD & 0x03);
106 | *portB = (data >> 6) | (*portB & 0xfc);
107 |
108 | wait(4);
109 | WR_LOW; // Write Data
110 | wait(4);
111 | WR_HIGH;
112 | wait(2);
113 | last_write_addr = addr;
114 | }
115 |
116 | /*! ステータスを読み込む、bit0のみ有効
117 | */
118 | uint8_t YM2151_Class::read()
119 | {
120 | uint8_t i,wi,data;
121 | volatile uint8_t *ddrD=&DDRD;
122 | volatile uint8_t *ddrB=&DDRB;
123 | volatile uint8_t *portD=&PORTD;
124 | volatile uint8_t *portB=&PORTB;
125 | *ddrD &= ~(_BV(2) | _BV(3) | _BV(4) | _BV(5) | _BV(6) | _BV(7));
126 | *ddrB &= ~(_BV(0) | _BV(1));
127 | A0_HIGH;
128 | wait(4);
129 | RD_LOW; // Read Data
130 | wait(4);
131 | data = 0;
132 | data |= (*portD)>>2;
133 | data |= (*portB)<<6;
134 | RD_HIGH;
135 | wait(4);
136 | }
137 |
138 | /*! 約300nSec x loop分だけ待つ、あまり正確でない。
139 | \param loop ループ数
140 | */
141 | void YM2151_Class::wait(uint8_t loop)
142 | {
143 | uint8_t wi;
144 | for(wi=0;wi15)ASSERT("Illegal volume.");
296 | tl = volume_tbl[volume];
297 | }
298 | tl += offset>>8;
299 | for(int i=0;i<4;i++){
300 | if(CarrierSlot[ch] & (1< 0x7f || att < 0) att=0x7f;
306 | write(0x60 + i*8 + ch,att);
307 | }
308 | }
309 |
310 | /*! ノートオンする
311 | \param ch オンするチャンネル
312 | */
313 | void YM2151_Class::noteOn(uint8_t ch)
314 | {
315 | write(0x08,(RegSLOTMASK[ch] << 3) + ch);
316 | }
317 |
318 | /*! ノートオフする
319 | \param ch オフするチャンネル
320 | */
321 | void YM2151_Class::noteOff(uint8_t ch)
322 | {
323 | write(0x08,0x00 + ch);
324 | }
325 |
326 | const char KeyCodeTable[] PROGMEM= {
327 | 0x00,0x01,0x02,0x04,0x05,0x06,0x08,0x09,
328 | 0x0a,0x0c,0x0d,0x0e,0x10,0x11,0x12,0x14,
329 | 0x15,0x16,0x18,0x19,0x1a,0x1c,0x1d,0x1e,
330 | 0x20,0x21,0x22,0x24,0x25,0x26,0x28,0x29,
331 | 0x2a,0x2c,0x2d,0x2e,0x30,0x31,0x32,0x34,
332 | 0x35,0x36,0x38,0x39,0x3a,0x3c,0x3d,0x3e,
333 | 0x40,0x41,0x42,0x44,0x45,0x46,0x48,0x49,
334 | 0x4a,0x4c,0x4d,0x4e,0x50,0x51,0x52,0x54,
335 | 0x55,0x56,0x58,0x59,0x5a,0x5c,0x5d,0x5e,
336 | 0x60,0x61,0x62,0x64,0x65,0x66,0x68,0x69,
337 | 0x6a,0x6c,0x6d,0x6e,0x70,0x71,0x72,0x74,
338 | 0x75,0x76,0x78,0x79,0x7a,0x7c,0x7d,0x7e,
339 | };
340 |
341 | /*! 音程を設定する
342 | \param ch 設定するチャンネル
343 | \param keycode オクターブ0のD#を0とした音階、D# E F F# G G# A A# B (オクターブ1) C C# D....と並ぶ
344 | \param kf 音階微調整、64で1音分上がる。
345 | */
346 | void YM2151_Class::setTone(uint8_t ch,uint8_t keycode,int16_t kf){
347 | int16_t offset_kf = (kf & 0x3f);
348 | int16_t offset_note = keycode + (kf >> 6);
349 | if(offset_note < 0)offset_note=0;
350 | if(offset_note > 0xbf)offset_note=0xbf;
351 |
352 | write(0x30 + ch, offset_kf<<2);
353 | write(0x28 + ch, pgm_read_byte_near(KeyCodeTable + offset_note));
354 | }
355 | /*! パンポットを設定する
356 | \param ch 設定するチャンネル
357 | \param pan パン設定、0:出力なし 1:左 2:右 3:両出力
358 | */
359 | void YM2151_Class::setPanpot(uint8_t ch,uint8_t pan){
360 | write(0x20+ch,
361 | (pan<<6) | (RegFLCON[ch] ));
362 |
363 | }
364 |
--------------------------------------------------------------------------------
/SketchMDXPlayer/YM2151.h:
--------------------------------------------------------------------------------
1 | #if !defined( YM2151_H_INCLUDED )
2 | #define YM2151_H_INCLUDED
3 | #include
4 |
5 | class YM2151_Class{
6 | public:
7 | YM2151_Class();
8 | void begin();
9 | void initLFO();
10 | uint8_t read();
11 | void write(uint8_t addr,uint8_t data);
12 |
13 | void setTone(uint8_t ch,uint8_t keycode,int16_t kf);
14 | void setVolume(uint8_t ch,uint8_t volume,uint16_t offset);
15 | void noteOn(uint8_t ch);
16 | void noteOff(uint8_t ch);
17 | void loadTimbre(uint8_t ch,uint16_t prog_addr);
18 | void loadSeparationTimbre(uint8_t ch,uint16_t prog_addr);
19 | void dumpTimbre(uint16_t prog_addr);
20 | void setPanpot(uint8_t ch,uint8_t pan);
21 | private:
22 | static const uint8_t PIN_D0=2;
23 | static const uint8_t PIN_D1=3;
24 | static const uint8_t PIN_D2=4;
25 | static const uint8_t PIN_D3=5;
26 | static const uint8_t PIN_D4=6;
27 | static const uint8_t PIN_D5=7;
28 | static const uint8_t PIN_D6=8;
29 | static const uint8_t PIN_D7=9;
30 |
31 | static const uint8_t PIN_RD=10;
32 | static const uint8_t PIN_WR=11;
33 | static const uint8_t PIN_ADDR0=12;
34 | static const uint8_t PIN_IC=13;
35 |
36 | uint8_t RegFLCON[8];
37 | uint8_t RegSLOTMASK[8];
38 | uint8_t CarrierSlot[8];
39 | uint8_t RegTL[8][4];
40 |
41 | void wait(uint8_t loop);
42 | };
43 | extern YM2151_Class YM2151;
44 | #endif //YM2151H_INCLUDED
45 |
--------------------------------------------------------------------------------
/YM2151ShieldKitManual-0.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/YM2151ShieldKitManual-0.1.pdf
--------------------------------------------------------------------------------
/YM2151ShieldKitManual_EN-0.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/YM2151ShieldKitManual_EN-0.1.pdf
--------------------------------------------------------------------------------
/YM2151ShieldR3Gerber.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooISHoo/Arduino_YM2151/a02a84bf0ed4755575fe8b358b6f1bac6050d49c/YM2151ShieldR3Gerber.zip
--------------------------------------------------------------------------------