Skip to content

Commit

Permalink
TAG751 2024/12/7 2nd
Browse files Browse the repository at this point in the history
  Core:OPN系(OPNA2除く):yDT,yML,yyDT,yyML,yKS,yAR,yyKS,yyAR,yAM,yDR,yyAM,yyDR,ySL,yRR,yySL,yyRRコマンド追加
  • Loading branch information
kumatan committed Dec 7, 2024
1 parent 43d1c74 commit a7a1bcf
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 22 deletions.
3 changes: 3 additions & 0 deletions mml2vgm/CHANGE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
�X�V����
TAG751 2024/12/7 2nd
Core:OPN�n(OPNA2����):yDT,yML,yyDT,yyML,yKS,yAR,yyKS,yyAR,yAM,yDR,yyAM,yyDR,ySL,yRR,yySL,yyRR�R�}���h�lj�

TAG750 2024/12/7
mvc:x64 .NET8 �ŐV�K�쐬
Core:x64 .NET8 �ŐV�K�쐬(mml2vgmx64,mml2vgmIDEx64,mvcx64�Ŏg�p���܂�)
Expand Down
2 changes: 2 additions & 0 deletions mml2vgm/Core/chips/clsOPN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ public void OutFmSetInstrument(partPage page, MML mml, int n, int vol, char type
break;
}

page.currentInstrument = parent.instFM[n];

if (!(page.chip is YM2612X2))
{
for (int ope = 0; ope < 4; ope++)
Expand Down
2 changes: 2 additions & 0 deletions mml2vgm/Core/partPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ public class partPage
public int RR15 { get; set; } = 0;
public int voperator { get; set; } = 0;
public bool vguard { get; set; } = false;
public Tuple<string, byte[]> currentInstrument { get; set; }

public Dictionary<byte, byte> TLOFS = new Dictionary<byte, byte>();

public bool PASwitch = false;
Expand Down
107 changes: 85 additions & 22 deletions mml2vgm/Corex64/MMLAnalyze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;

namespace Corex64
{
Expand Down Expand Up @@ -2672,51 +2673,116 @@ private void CmdEffectHPF(partWork pw, partPage page, MML mml)
if (relative != 0) mml.args.Add(relative);
}

private static readonly string[] YcmdTbl =
[
//長い順に定義すること
"PANFLCON" //,n1
,"PANFBAL" //,n1
,"PMSAMS" //,n1
,"DT1MUL" //,n1,n2
,"AMED1R" //,n1,n2
,"DT2D2R" //,n1,n2
,"DTMUL" //,n1,n2
,"DT1ML" //,n1,n2
,"DT2SR" //,n1,n2
,"D1LRR" //,n1,n2
,"DTML" //,n1,n2
,"KSAR" //,n1,n2
,"AMDR" //,n1,n2
,"SLRR" //,n1,n2
,"FBAL" //,n1
,"SSG" //,n1,n2
,"DT1" //,n1,n2
,"MUL" //,n1,n2
,"DT2" //,n1,n2
,"D1L" //,n1,n2
,"D2R" //,n1,n2
,"AME" //,n1,n2
,"PAN" //,n1
,"CON" //,n1
,"PMS" //,n1
,"AMS" //,n1
,"TL" //,n1,n2
,"SR" //,n1,n2
,"DT" //,n1,n2
,"ML" //,n1,n2
,"KS" //,n1,n2
,"AR" //,n1,n2
,"AM" //,n1,n2
,"DR" //,n1,n2
,"SL" //,n1,n2
,"RR" //,n1,n2
,"FB" //,n1
,"AL" //,n1
];

private void CmdY(partWork pw, partPage page, MML mml)
{
int n = -1;
int dat = 0;
int op = 0;
pw.incPos(page);
bool relative = false;

char c = pw.getChar(page);
if (c == 'y')
{
relative = true;
pw.incPos(page);
c = pw.getChar(page);
}

if (c >= 'A' && c <= 'Z')
{
//とりあえず最長のコマンド分まで読み込む
string toneparamName = "" + c;
pw.incPos(page);
toneparamName += pw.getChar(page);
pw.incPos(page);
if (toneparamName != "TL" && toneparamName != "SR")
for (int i = 0; i < YcmdTbl[0].Length - 1; i++)
{
toneparamName += pw.getChar(page);
pw.incPos(page);
if (toneparamName != "SSG")
{
toneparamName += pw.getChar(page);
pw.incPos(page);
}
}

if (toneparamName == "DT1M" || toneparamName == "DT2S" || toneparamName == "PMSA")
for (int i = 0; i < toneparamName.Length - 1; i++) pw.decPos(page);
//コマンドテーブルと順に比較
bool fnd = false;
foreach(string cmd in YcmdTbl)
{
toneparamName += pw.getChar(page);
pw.incPos(page);
if (toneparamName == "PMSAM")
{
toneparamName += pw.getChar(page);
pw.incPos(page);
}
if(cmd.Length < toneparamName.Length)
toneparamName = toneparamName.Substring(0, cmd.Length);
if (cmd != toneparamName) continue;
fnd = true;
break;
}
if (!fnd)
{
msgBox.setErrMsg(msg.get("E05091"), mml.line.Lp);
return;
}
for (int i = 0; i < toneparamName.Length - 1; i++) pw.incPos(page);

pw.skipTabSpace(page);
pw.incPos(page);
pw.skipTabSpace(page);

if (toneparamName != "FBAL" && toneparamName != "PMSAMS")
if (toneparamName != "PANFLCON"
&& toneparamName != "PANFBAL"
&& toneparamName != "PMSAMS"
&& toneparamName != "FBAL"
&& toneparamName != "PAN"
&& toneparamName != "CON"
&& toneparamName != "PMS"
&& toneparamName != "AMS"
&& toneparamName != "FB"
&& toneparamName != "AL"
)
{
if (pw.getNum(page, out n))
{
op = (byte)(Common.CheckRange(n & 0xff, 1, 4) - 1);
}
pw.skipTabSpace(page);
pw.incPos(page);
pw.skipTabSpace(page);
}

if (pw.getNum(page, out n))
Expand All @@ -2725,10 +2791,7 @@ private void CmdY(partWork pw, partPage page, MML mml)
}

mml.type = enmMMLType.Y;
mml.args = new List<object>();
mml.args.Add(toneparamName);
mml.args.Add(op);
mml.args.Add(dat);
mml.args = [toneparamName + (relative ? "+-" : ""), op, dat];
return;
}

Expand Down
2 changes: 2 additions & 0 deletions mml2vgm/Corex64/chips/YM2609.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,8 @@ public void OutFmSetALGLinkSSGEG(MML mml, partPage page, int ope, int all, int s
break;
}

page.currentInstrument = CopyInstrument(parent.instFM[n]);

if (parent.instFM[n].Item2.Length == Const.OPNA2_INSTRUMENT_SIZE)
{
OutFmSetInstrumentOPNA(page,vpg, mml, n, vol,UMop,isDef, FBALG);
Expand Down
143 changes: 143 additions & 0 deletions mml2vgm/Corex64/chips/clsOPN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ public void OutFmSetInstrument(partPage page, MML mml, int n, int vol, char type
break;
}

page.currentInstrument = CopyInstrument(parent.instFM[n]);

if (!(page.chip is YM2612X2))
{
for (int ope = 0; ope < 4; ope++)
Expand Down Expand Up @@ -1424,6 +1426,18 @@ public void OutFmSetInstrument(partPage page, MML mml, int n, int vol, char type

}

protected Tuple<string, byte[]> CopyInstrument(Tuple<string, byte[]> inst)
{
if (inst == null) return null;
if (inst.Item2 == null) return null;

string nm = inst.Item1;
List<byte> dat = [];
foreach (byte b in inst.Item2) dat.Add(b);

return new Tuple<string, byte[]>(nm, [.. dat]);
}

public virtual void OutFmKeyOff(partPage page, MML mml)
{
int n = (page.chip is YM2203) ? 0 : 3;
Expand Down Expand Up @@ -3119,26 +3133,155 @@ public override void CmdY(partPage page, MML mml)
byte op = (byte)(int)mml.args[1];
byte dat = (byte)(int)mml.args[2];

int dt, ml, ks, ar, am, dr, sl, rr;
switch (toneparamName)
{
case "DTML":
CmdY_ToneParamOPN(mml, 0x30, page, op, dat);
break;
case "DT":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 7);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 9] = dat;
dt = dat;
ml = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 8];
OutFmSetDtMl(mml, page, op, dt, ml);
break;
case "ML":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 15);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 8] = dat;
dt = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 9];
ml = dat;
OutFmSetDtMl(mml, page, op, dt, ml);
break;
case "DT+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 9] + (sbyte)dat) & 7);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 9] = dat;
dt = dat;
ml = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 8];
OutFmSetDtMl(mml, page, op, dt, ml);
break;
case "ML+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 8] + (sbyte)dat) & 15);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 8] = dat;
dt = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 9];
ml = dat;
OutFmSetDtMl(mml, page, op, dt, ml);
break;
case "TL":
CmdY_ToneParamOPN(mml, 0x40, page, op, dat);
break;
case "KSAR":
CmdY_ToneParamOPN(mml, 0x50, page, op, dat);
break;
case "KS":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 3);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 7] = dat;
ks = dat;
ar = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 1];
OutFmSetKsAr(mml, page, op, ks, ar);
break;
case "AR":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 31);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 1] = dat;
ks = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 7];
ar = dat;
OutFmSetKsAr(mml, page, op, ks, ar);
break;
case "KS+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 7] + (sbyte)dat) & 3);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 7] = dat;
ks = dat;
ar = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 1];
OutFmSetKsAr(mml, page, op, ks, ar);
break;
case "AR+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 1] + (sbyte)dat) & 31);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 1] = dat;
ks = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 7];
ar = dat;
OutFmSetKsAr(mml, page, op, ks, ar);
break;
case "AMDR":
CmdY_ToneParamOPN(mml, 0x60, page, op, dat);
break;
case "AM":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 1);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 10] = dat;
am = dat;
dr = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 2];
OutFmSetAmDr(mml, page, op, am, dr);
break;
case "DR":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 31);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 2] = dat;
am = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 10];
dr = dat;
OutFmSetAmDr(mml, page, op, am, dr);
break;
case "AM+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 10] + (sbyte)dat) & 1);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 10] = dat;
am = dat;
dr = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 2];
OutFmSetAmDr(mml, page, op, am, dr);
break;
case "DR+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 2] + (sbyte)dat) & 31);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 2] = dat;
am = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 10];
dr = dat;
OutFmSetAmDr(mml, page, op, am, dr);
break;
case "SR":
CmdY_ToneParamOPN(mml, 0x70, page, op, dat);
break;
case "SLRR":
CmdY_ToneParamOPN(mml, 0x80, page, op, dat);
break;
case "SL":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 15);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 5] = dat;
sl = dat;
rr = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 4];
OutFmSetSlRr(mml, page, op, sl, rr);
break;
case "RR":
if (page.currentInstrument == null) break;
dat = (byte)(dat & 15);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 4] = dat;
sl = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 5];
rr = dat;
OutFmSetSlRr(mml, page, op, sl, rr);
break;
case "SL+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 5] + (sbyte)dat) & 15);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 5] = dat;
sl = dat;
rr = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 4];
OutFmSetSlRr(mml, page, op, sl, rr);
break;
case "RR+-":
if (page.currentInstrument == null) break;
dat = (byte)((page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 4] + (sbyte)dat) & 15);
page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 4] = dat;
sl = page.currentInstrument.Item2[op * Const.INSTRUMENT_M_OPERATOR_SIZE + 5];
rr = dat;
OutFmSetSlRr(mml, page, op, sl, rr);
break;
case "SSG":
CmdY_ToneParamOPN(mml, 0x90, page, op, dat);
break;
Expand Down
1 change: 1 addition & 0 deletions mml2vgm/Corex64/lang/message.ja-JP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ E05087='TLOFS'コマンドの解析に失敗しました。
E05088=使用できないスロット番号が指定されています。slotは使用するslotの番号(1~4)を列挙します。
E05089=指定できる数値の範囲を超えています
E05090='VGON/VGOF'コマンドの解析に失敗しました。
E05091='y'コマンドの解析に失敗しました。


;partWork.cs 06000
Expand Down
1 change: 1 addition & 0 deletions mml2vgm/Corex64/lang/message.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ E05087=Unknown command ('TLOFS?') defined.
E05088=A slot number is specified that cannot be used. slot enumerates the number of slots (1-4) to be used.
E05089=The value exceeds the range of values that can be specified.
E05090=Unknown command ('VGO?') defined.
E05091=Unknown command ('y') defined.


;partWork.cs 06000
Expand Down
2 changes: 2 additions & 0 deletions mml2vgm/Corex64/partPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ public class partPage
public int RR15 { get; set; } = 0;
public int voperator { get; set; } = 0;
public bool vguard { get; set; } = false;
public Tuple<string, byte[]> currentInstrument { get; set; }

public Dictionary<byte, byte> TLOFS = new Dictionary<byte, byte>();

public bool PASwitch = false;
Expand Down
Loading

0 comments on commit a7a1bcf

Please sign in to comment.