Skip to content

Commit 5f679fe

Browse files
committed
- 5.9.0.0 Supported NanoDrive 6 UART for OPN2, DCSG.
1 parent d42f2ac commit 5f679fe

File tree

18 files changed

+573
-76
lines changed

18 files changed

+573
-76
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MAmidiMEmo 5.8.2.0 Itoken (c)2019, 2025 / GPL-2.0
1+
MAmidiMEmo 5.9.0.0 Itoken (c)2019, 2025 / GPL-2.0
22

33
*** What is the MAmidiMEmo? ***
44

@@ -274,6 +274,7 @@ e.g.) YM2151 has 8ch FM sounds, so you can play 8 chords on MIDI 1ch or sharing
274274
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNQ9JE3JAQMNQ)
275275

276276
*** Changes
277+
- 5.9.0.0 Supported NanoDrive 6 UART for OPN2, DCSG.
277278
- 5.8.2.0 Added Push/Pop Tone button on the FM Timbre Editor.
278279
- 5.8.1.6 Supported a VRC7 VGM file by VGMPlayer w/ MAmiCart + VRC7 cart.
279280
- 5.8.1.5 Re-fixed FTDI clk handling for NES.

src/VSIF/VGMPlayer/FormMain.Designer.cs

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/VSIF/VGMPlayer/FormMain.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,10 @@ private void checkBoxConnDCSG_CheckedChanged(object sender, EventArgs e)
11561156
if (comPortDCSG != null)
11571157
comPortDCSG.DeferredWriteData(0x15, (byte)0x0, (byte)127, (int)Settings.Default.BitBangWaitDCSG);
11581158
break;
1159+
case 7:
1160+
comPortDCSG = VsifManager.TryToConnectVSIF(VsifSoundModuleType.NanoDrive,
1161+
(PortId)Settings.Default.DCSG_Port, (int)Settings.Default.DCSGDiv, false);
1162+
break;
11591163
}
11601164

11611165
checkBoxConnDCSG.Checked = comPortDCSG != null;
@@ -1252,6 +1256,10 @@ private void checkBoxConnOPN2_CheckedChanged(object sender, EventArgs e)
12521256
if (comPortOPN2 != null)
12531257
comPortOPN2.DeferredWriteData(0x15, (byte)0x0, (byte)127, (int)Settings.Default.BitBangWaitOPN2);
12541258
break;
1259+
case 5:
1260+
comPortOPN2 = VsifManager.TryToConnectVSIF(VsifSoundModuleType.NanoDrive,
1261+
(PortId)Settings.Default.OPN2_Port, (int)Settings.Default.OPN2Div, false);
1262+
break;
12551263
}
12561264
checkBoxConnOPN2.Checked = comPortOPN2 != null;
12571265
comboBoxOPN2.Enabled = comPortOPN2 == null;

src/VSIF/VGMPlayer/FormMain.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
129129
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
130130
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD+
131-
ZQAAAk1TRnQBSQFMAgEBCgEAAUABGgFAARoBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
131+
ZQAAAk1TRnQBSQFMAgEBCgEAAVABGgFQARoBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
132132
AwABYAMAAQEBAAEgBgABwMIAA3kB/wNbAf8BTQFMAU0B/wNLAf8BTQFMAU0B/wNZAf8DdwH/A6IB//8A
133133
1QADcwH/A0wB/wNLAf8DSwH/A0sB/wNLAf8DSwH/A0sB/wNLAf8DSwH/A0sB/wNLAf8DbQH//wDFAAN+
134134
Af8DSwH/A0sB/wNLAf8DTwH/A3QB/wOaAf8MAAKaAZsB/wN4Af8DUAH/A0sB/wNLAf8DSwH/A3kB//8A
@@ -577,7 +577,7 @@
577577
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
578578
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
579579
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAB6
580-
aQAAAk1TRnQBSQFMAgEBAgEAAUABGgFAARoBQAEAAUABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgEAAEB
580+
aQAAAk1TRnQBSQFMAgEBAgEAAVABGgFQARoBQAEAAUABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgEAAEB
581581
AgABQAMAAQEBAAEgBwABAWUAAwYBBwMSARcDHAEnAyUBNgM+AWoDRwGBA04BmANVAa8DWwHFA14B3QNg
582582
AfMDYAHzA14B3QNbAcUDVQGvA04BmANHAYEDPgFqAyUBNgMcAScDEgEXAwYBB6gAAwYBBwMSARcDHAEn
583583
AyUBNgM+AWoDRwGBA04BmANVAa8DWwHFA14B3QNgAfMDYAHzA14B3QNbAcUDVQGvA04BmANHAYEDPgFq
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using FTD2XX_NET;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Diagnostics;
5+
using System.IO.Ports;
6+
using System.Linq;
7+
using System.Runtime.InteropServices;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace zanac.VGMPlayer
12+
{
13+
public class PortWriterNanoDrive : PortWriter
14+
{
15+
/// <summary>
16+
///
17+
/// </summary>
18+
/// <param name="serialPort"></param>
19+
public PortWriterNanoDrive(SerialPort serialPort) : base(serialPort)
20+
{
21+
}
22+
23+
/// <summary>
24+
///
25+
/// </summary>
26+
/// <param name="ftdiPort"></param>
27+
public PortWriterNanoDrive(FTDI ftdiPort, PortId portNo) : base(ftdiPort, portNo)
28+
{
29+
}
30+
31+
/// <summary>
32+
///
33+
/// </summary>
34+
/// <param name="type"></param>
35+
/// <param name="address"></param>
36+
/// <param name="data"></param>
37+
/// <param name="wait"></param>
38+
public override void Write(PortWriteData[] data)
39+
{
40+
try
41+
{
42+
List<byte> ds = new List<byte>();
43+
foreach (var dt in data)
44+
{
45+
switch (dt.Type)
46+
{
47+
//PSG (SN76489/SN76496) write value dd
48+
case 0x50:
49+
ds.Add(dt.Type);
50+
ds.Add(dt.Data);
51+
break;
52+
//YM2612 port 0, write value dd to register aa
53+
case 0x52:
54+
//YM2612 port 1, write value dd to register aa
55+
case 0x53:
56+
ds.Add(dt.Type);
57+
ds.Add(dt.Address);
58+
ds.Add(dt.Data);
59+
break;
60+
}
61+
}
62+
63+
byte[] dsa = ds.ToArray();
64+
lock (LockObject)
65+
SerialPort?.Write(dsa, 0, dsa.Length);
66+
}
67+
catch (Exception ex)
68+
{
69+
if (ex.GetType() == typeof(Exception))
70+
throw;
71+
else if (ex.GetType() == typeof(SystemException))
72+
throw;
73+
}
74+
}
75+
76+
/// <summary>
77+
///
78+
/// </summary>
79+
/// <param name="data"></param>
80+
/// <param name="wait"></param>
81+
public override void RawWrite(byte[] data, int[] wait)
82+
{
83+
try
84+
{
85+
lock (LockObject)
86+
SerialPort?.Write(data, 0, data.Length);
87+
}
88+
catch (Exception ex)
89+
{
90+
if (ex.GetType() == typeof(Exception))
91+
throw;
92+
else if (ex.GetType() == typeof(SystemException))
93+
throw;
94+
}
95+
}
96+
97+
}
98+
99+
}

src/VSIF/VGMPlayer/SongBase.cs

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ protected void LoadCoverArt()
437437
completed = true;
438438
},
439439
() => { cancelled = true; });
440-
}
441-
break;
440+
}
441+
break;
442442
}
443443
if (completed)
444444
break;
@@ -545,9 +545,9 @@ protected virtual void Dispose(bool disposing)
545545
playTicTimer?.Dispose();
546546
playTicTimer = null;
547547

548-
if(DeleteFileAfterStop)
548+
if (DeleteFileAfterStop)
549549
File.Delete(FileName);
550-
if(DeleteCoverArtFileAfterStop)
550+
if (DeleteCoverArtFileAfterStop)
551551
File.Delete(CoverArtFile);
552552
}
553553
}
@@ -1274,6 +1274,9 @@ protected void deferredWriteOPNA_P0(VsifClient comPortOPNA, int adrs, int dt)
12741274
comPortOPNA.DeferredWriteData(0x00, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPNA);
12751275
}
12761276
break;
1277+
case VsifSoundModuleType.NanoDrive:
1278+
comPortOPNA.DeferredWriteData(0x52, (byte)adrs, (byte)dt, 0);
1279+
break;
12771280
}
12781281
}
12791282

@@ -1367,6 +1370,9 @@ protected void deferredWriteOPNA_P1(VsifClient comPortOPNA, int adrs, int dt)
13671370
else
13681371
comPortOPNA.DeferredWriteData(0x01, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPNA);
13691372
break;
1373+
case VsifSoundModuleType.NanoDrive:
1374+
comPortOPNA.DeferredWriteData(0x53, (byte)adrs, (byte)dt, 0);
1375+
break;
13701376
}
13711377
}
13721378

@@ -1402,18 +1408,23 @@ public void DeferredWriteOPN2_DAC(VsifClient comPortOPN2, int dacValue)
14021408
if (lastOpn2DacValue == dacValue)
14031409
return;
14041410

1405-
if (comPortOPN2.SoundModuleType == VsifSoundModuleType.MSX_FTDI ||
1406-
comPortOPN2.SoundModuleType == VsifSoundModuleType.TurboR_FTDI)
1411+
switch (comPortOPN2.SoundModuleType)
14071412
{
1408-
comPortOPN2.DeferredWriteData(0x14, (byte)0x2a, (byte)dacValue, (int)Program.Default.BitBangWaitOPN2);
1409-
}
1410-
else //Genesis
1411-
{
1412-
comPortOPN2.DeferredWriteDataPrior(
1413-
new byte[] { 0, 0 },
1414-
new byte[] { 0x04, 0x8 },
1415-
new byte[] { (byte)0x2a, (byte)dacValue },
1416-
(int)Program.Default.BitBangWaitOPN2);
1413+
case VsifSoundModuleType.MSX_FTDI:
1414+
case VsifSoundModuleType.TurboR_FTDI:
1415+
comPortOPN2.DeferredWriteData(0x14, (byte)0x2a, (byte)dacValue, (int)Program.Default.BitBangWaitOPN2);
1416+
break;
1417+
case VsifSoundModuleType.NanoDrive:
1418+
comPortOPN2.DeferredWriteData(0x52, (byte)0x2a, (byte)dacValue, (int)Program.Default.BitBangWaitOPN2);
1419+
break;
1420+
default:
1421+
//Genesis
1422+
comPortOPN2.DeferredWriteDataPrior(
1423+
new byte[] { 0, 0 },
1424+
new byte[] { 0x04, 0x8 },
1425+
new byte[] { (byte)0x2a, (byte)dacValue },
1426+
(int)Program.Default.BitBangWaitOPN2);
1427+
break;
14171428
}
14181429
lastOpn2DacValue = dacValue;
14191430
}
@@ -1552,18 +1563,23 @@ protected void deferredWriteOPN2_P0(VsifClient comPortOPN2, int adrs, int dt, ui
15521563
/// <param name="dt"></param>
15531564
protected void deferredWriteOPN2_P0(VsifClient comPortOPN2, int adrs, int dt)
15541565
{
1555-
if (comPortOPN2.SoundModuleType == VsifSoundModuleType.MSX_FTDI ||
1556-
comPortOPN2.SoundModuleType == VsifSoundModuleType.TurboR_FTDI)
1566+
switch (comPortOPN2.SoundModuleType)
15571567
{
1558-
comPortOPN2.DeferredWriteData(0x10, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPN2);
1559-
}
1560-
else //Genesis
1561-
{
1562-
comPortOPN2.DeferredWriteData(
1563-
new byte[] { 0, 0 },
1564-
new byte[] { 0x04, 0x8 },
1565-
new byte[] { (byte)adrs, (byte)dt },
1566-
(int)Program.Default.BitBangWaitOPN2);
1568+
case VsifSoundModuleType.MSX_FTDI:
1569+
case VsifSoundModuleType.TurboR_FTDI:
1570+
comPortOPN2.DeferredWriteData(0x10, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPN2);
1571+
break;
1572+
case VsifSoundModuleType.NanoDrive:
1573+
comPortOPN2.DeferredWriteData(0x52, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPN2);
1574+
break;
1575+
default:
1576+
//Genesis
1577+
comPortOPN2.DeferredWriteData(
1578+
new byte[] { 0, 0 },
1579+
new byte[] { 0x04, 0x8 },
1580+
new byte[] { (byte)adrs, (byte)dt },
1581+
(int)Program.Default.BitBangWaitOPN2);
1582+
break;
15671583
}
15681584
}
15691585

@@ -1628,18 +1644,23 @@ protected void deferredWriteOPN2_P1(VsifClient comPortOPN2, int adrs, int dt, ui
16281644
/// <param name="dt"></param>
16291645
protected void deferredWriteOPN2_P1(VsifClient comPortOPN2, int adrs, int dt)
16301646
{
1631-
if (comPortOPN2.SoundModuleType == VsifSoundModuleType.MSX_FTDI ||
1632-
comPortOPN2.SoundModuleType == VsifSoundModuleType.TurboR_FTDI)
1633-
{
1634-
comPortOPN2.DeferredWriteData(0x11, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPN2);
1635-
}
1636-
else
1647+
switch (comPortOPN2.SoundModuleType)
16371648
{
1638-
comPortOPN2.DeferredWriteData(
1639-
new byte[] { 0, 0 },
1640-
new byte[] { 0x0C, 0x10 },
1641-
new byte[] { (byte)adrs, (byte)dt },
1642-
(int)Program.Default.BitBangWaitOPN2);
1649+
case VsifSoundModuleType.MSX_FTDI:
1650+
case VsifSoundModuleType.TurboR_FTDI:
1651+
comPortOPN2.DeferredWriteData(0x11, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPN2);
1652+
break;
1653+
case VsifSoundModuleType.NanoDrive:
1654+
comPortOPN2.DeferredWriteData(0x53, (byte)adrs, (byte)dt, (int)Program.Default.BitBangWaitOPN2);
1655+
break;
1656+
default:
1657+
//Genesis
1658+
comPortOPN2.DeferredWriteData(
1659+
new byte[] { 0, 0 },
1660+
new byte[] { 0x0C, 0x10 },
1661+
new byte[] { (byte)adrs, (byte)dt },
1662+
(int)Program.Default.BitBangWaitOPN2);
1663+
break;
16431664
}
16441665
}
16451666

src/VSIF/VGMPlayer/VGMPlayer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
<Compile Include="FormWeb.Designer.cs">
177177
<DependentUpon>FormWeb.cs</DependentUpon>
178178
</Compile>
179+
<Compile Include="PortWriterNanoDrive.cs" />
179180
<Compile Include="TurboLink\TurboEvedriveManager.cs" />
180181
<Compile Include="Gimic\GimicManager.cs" />
181182
<Compile Include="Gimic\NativeC86CtlWrapper.cs" />

0 commit comments

Comments
 (0)