Skip to content

Commit

Permalink
TAG041 2020/09/03
Browse files Browse the repository at this point in the history
  他アプリとの連携のための微調整(@:Instrument)
  • Loading branch information
kumatan committed Sep 3, 2020
1 parent 96bf9af commit b9c8e49
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
�X�V����
TAG041 2020/09/03
���A�v���Ƃ̘A�g�̂��߂̔�����(@:Instrument)

TAG040 2020/08/31
���A�v���Ƃ̘A�g�̂��߂̔�����(Q,q:GateTime)

Expand Down
9 changes: 7 additions & 2 deletions PMDDotNETCompiler/hs_seg.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using musicDriverInterface;
using System;
using System.Collections.Generic;
using System.Text;

Expand All @@ -10,6 +11,10 @@ public class hs_seg
public byte[] hsbuf2 = new byte[2 * 256];
public byte[] hsbuf3 = new byte[32 * 256];// hs_length * 256];
public int hsbuf_end;// label byte
internal byte[] currentBuf;
public byte[] currentBuf;

public LinePos[] hsLp2 = new LinePos[256];
public LinePos[] hsLp3 = new LinePos[256];
public LinePos[] currentLp;
}
}
58 changes: 53 additions & 5 deletions PMDDotNETCompiler/mc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ private void ReadMMLFileName(int i)
#endif
}

mml_seg.includeFileHistory.Clear();
mml_seg.includeFileHistory.Add(mml_seg.mml_filename);
}


Expand Down Expand Up @@ -1111,6 +1113,11 @@ private enmPass2JumpTable cmloop2()
#endif

Log.WriteLine(LogLevel.DEBUG, string.Format("Part: {0} compile start" , (char)('A' - 1 + mml_seg.part) ));

//mml_seg.includeFileHistoryPos = 0;
//mml_seg.currentMMLFile = mml_seg.includeFileHistory[0];
//mml_seg.includeFileHistoryStack.Clear();
//mml_seg.includeFileLineStack.Clear();

return enmPass2JumpTable.cloop;
}
Expand All @@ -1131,6 +1138,21 @@ private enmPass2JumpTable cloop()
char al = (work.si < mml_seg.mml_buf.Length ? mml_seg.mml_buf[work.si++] : (char)0x1a);
if (al == 0x1a)
return enmPass2JumpTable.part_end;
if (al == 1)
{
//include file enter
//mml_seg.includeFileHistoryPos++;
//mml_seg.includeFileHistoryStack.Push(mml_seg.currentMMLFile);
//mml_seg.includeFileLineStack.Push(mml_seg.line);
//mml_seg.line = 0;
//mml_seg.currentMMLFile = mml_seg.includeFileHistory[mml_seg.includeFileHistoryPos];
}
if (al == 2)
{
//include file exit
//mml_seg.currentMMLFile = mml_seg.includeFileHistoryStack.Pop();
//mml_seg.line = mml_seg.includeFileLineStack.Pop();
}
if (al < (' ' + 1)) goto c_fin;
if (al == ';') goto c_fin;
if (al != '`') goto c_no_skip;
Expand Down Expand Up @@ -3100,6 +3122,8 @@ private void include_set()
int p_si = work.si;//SI= CR位置 を保存
work.si += 2;// SI= 次の行の先頭位置(に読み込む予定)

mml_seg.includeFileHistory.Add(mml_seg.mml_filename2);

//;------------------------------------------------------------------------------
//; 現在のMML残りをMMLバッファ末端に移動
//; I---------------I---------------I---------------I
Expand Down Expand Up @@ -6142,7 +6166,7 @@ private LinePos MakeLinePos()
p++;

return new LinePos(
mml_seg.mml_filename
mml_seg.currentMMLFile//.mml_filename
, Math.Max(mml_seg.line, 1)
, Math.Max(mml_seg.stPos - mml_seg.linehead + 1, 1)
, p - mml_seg.stPos
Expand Down Expand Up @@ -7542,11 +7566,18 @@ private enmPass2JumpTable neirochg()
nc00:;
if (mml_seg.part == mml_seg.pcmpart) goto repeat_check;
if (mml_seg.ongen == mml_seg.pcm_ex) goto repeat_check;
if (mml_seg.part != mml_seg.rhythm2) return enmPass2JumpTable.parset;
if (mml_seg.part != mml_seg.rhythm2)
{
work.ctype = enmMMLType.Instrument;
work.cargs = new object[] { };
return enmPass2JumpTable.parset;
}
if (mml_seg.towns_flg == 1) goto repeat_check;// townsの K = PCM part
if (mml_seg.skip_flag != 0) return enmPass2JumpTable.olc0;

m_seg.m_buf.Set(work.di++, new MmlDatum((byte)work.dx));
MmlDatum cmd;
cmd = new MmlDatum((byte)work.dx, enmMMLType.Instrument, MakeLinePos(), new object[] { } );
m_seg.m_buf.Set(work.di++, cmd);

mml_seg.length_check1 = 1;// 音長データがあったよ
mml_seg.length_check2 = 1;
Expand All @@ -7566,7 +7597,8 @@ private enmPass2JumpTable neirochg()
//work.bx *= 4;
//work.bx = (byte)work.bx;
work.bx += 0;//offset psgenvdat
m_seg.m_buf.Set(work.di++, new MmlDatum(0xf0));
cmd = new MmlDatum((byte)0xf0, enmMMLType.Instrument, MakeLinePos(), new object[] { });
m_seg.m_buf.Set(work.di++, cmd);
cx = 4;
if (work.bx > 9)
{
Expand All @@ -7586,7 +7618,12 @@ private enmPass2JumpTable neirochg()

repeat_check:;
ch = work.si < mml_seg.mml_buf.Length ? mml_seg.mml_buf[work.si] : (char)0x1a;
if (ch != ',') return enmPass2JumpTable.parset;
if (ch != ',')
{
work.ctype = enmMMLType.Instrument;
work.cargs = new object[] { };
return enmPass2JumpTable.parset;
}

int ax = work.dx;
ax = (byte)(ax >> 8) | (((byte)ax) * 0x100);
Expand Down Expand Up @@ -9340,13 +9377,16 @@ private enmPass2JumpTable hscom()
mml_seg.hscomSI.Push(work.si);
mml_seg.hsflag++;
work.si = ax;
calc_line(ref ax);
return enmPass2JumpTable.olc02;// olc0
}

private enmPass2JumpTable hscom_exit()
{
mml_seg.hsflag--;
work.si = mml_seg.hscomSI.Pop();
int ax = work.si;
calc_line(ref ax);

return enmPass2JumpTable.olc03;
}
Expand Down Expand Up @@ -9564,6 +9604,9 @@ private void calc_line(ref int si)
return;
}

mml_seg.includeFileHistoryPos = 0;
mml_seg.currentMMLFile = mml_seg.includeFileHistory[mml_seg.includeFileHistoryPos];

Stack<int> lineStack = new Stack<int>();
int bx = 0;
int ah = 0;// Main/Include Flag
Expand Down Expand Up @@ -9610,6 +9653,10 @@ private void calc_line(ref int si)
{
al = si < mml_seg.mml_buf.Length ? mml_seg.mml_buf[si++] : (char)0x1a;
} while (al != 0x0a);//ファイル名部分を飛ばす

mml_seg.includeFileHistoryStack.Push(mml_seg.currentMMLFile);
mml_seg.currentMMLFile = mml_seg.includeFileHistory[++mml_seg.includeFileHistoryPos];

break;
}
else if (al == 2)//Include->Main check code
Expand All @@ -9619,6 +9666,7 @@ private void calc_line(ref int si)
ah--;//Include階層を一つ減らす

si++;
mml_seg.currentMMLFile = mml_seg.includeFileHistoryStack.Pop();
break;
}

Expand Down
30 changes: 18 additions & 12 deletions PMDDotNETCompiler/mml_seg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class mml_seg
#endif
#endif

public string finmes = "Compile Completed.";
public string finmes = "Compile Completed.";
public string mes_crlf = "" + mc.cr + mc.lf + mc.eof;

public string mes_title = mc.cr + mc.lf + "演奏を開始します。" + mc.cr + mc.lf + mc.cr + mc.lf
Expand All @@ -91,7 +91,7 @@ public class mml_seg
public string mcopt_txt = "MCOPT=";

#if !tempo_old_flag
public int tempo = 0;
public int tempo = 0;
#endif
public int timerb = 0;//b
public int octave = 4;//b
Expand Down Expand Up @@ -212,8 +212,8 @@ public class mml_seg
public int lastprg = 0;//w

public int prsok = 0;//b 直前のbyte
// bit 1 ・・・ 音長
// bit 2 ・・・ 加工
// bit 1 ・・・ 音長
// bit 2 ・・・ 加工
// bit 3 ・・・ +タイ
// bit 4 ・・・ ポルタ
// bit 7 ・・・ リズム
Expand Down Expand Up @@ -310,7 +310,7 @@ public class mml_seg
//分散和音ワーク
public int bunsan_start;//w 開始オフセット
public byte bunsan_count;//b 音符数
public byte[] bunsan_work=new byte[16];// 音階x16
public byte[] bunsan_work = new byte[16];// 音階x16
public byte bunsan_length;//b 全体の長さ
public byte bunsan_1cnt;//b 一音符の長さ
public byte bunsan_tieflag;//b タイフラグ
Expand Down Expand Up @@ -340,19 +340,25 @@ public class mml_seg
public int[] memo_adr = new int[129];//w
public string composer_seg = null;//w
public string arranger_seg = null;//w
//public string composer_adr;//w
//public string arranger_adr;//w
//public string composer_adr;//w
//public string arranger_adr;//w

public string mml_buf = null;//61*1024-1 dup(?); max 61k(.mml file)
public byte mmlbuf_end;//b

public Stack<int> hscomSI = new Stack<int>();
internal byte ontei;
internal int stPos;
internal int chipCh;
internal byte ontei;
internal int stPos;
internal int chipCh;

//mml_seg ends
public List<string> includeFileHistory = new List<string>();
public int includeFileHistoryPos;
public string currentMMLFile;
public Stack<string> includeFileHistoryStack = new Stack<string>();
//public Stack<int> includeFileLineStack = new Stack<int>();

//mml_seg ends

}

}
}
9 changes: 9 additions & 0 deletions PMDDotNETDriver/PCMDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,15 @@ private Func<object> comAtm()
{
r.al = (byte)pw.md[r.si++].dat;
pw.partWk[r.di].voicenum = r.al;

//IDE向け
ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = new MmlDatum(-1, enmMMLType.Instrument, pw.cmd.linePos
, (int)0xff
, (int)pw.partWk[r.di].voicenum
);
pmd.WriteDummy(cd);

r.ah = 0;
r.ax += r.ax;
r.ax += r.ax;
Expand Down
9 changes: 9 additions & 0 deletions PMDDotNETDriver/PMD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4445,6 +4445,15 @@ private Func<object> comAt()

r.al = (byte)pw.md[r.si++].dat;
pw.partWk[r.di].voicenum = r.al;

//IDE向け
ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = new MmlDatum(-1, enmMMLType.Instrument, pw.cmd.linePos
, (int)0xff
, (int)pw.partWk[r.di].voicenum
);
WriteDummy(cd);

r.dl = r.al;
if (pw.partWk[r.di].partmask != 0)//;パートマスクされているか?
goto comAt_mask;
Expand Down
13 changes: 11 additions & 2 deletions PMDDotNETDriver/PPZDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ private Func<object> pansetz_ex()
private Func<object> comAtz()
{
Func<object> ret = null;
ChipDatum cd;

r.al = (byte)pw.md[r.si++].dat;
if (pw.ademu != 0)
Expand All @@ -735,13 +736,21 @@ private Func<object> comAtz()
r.stack.Push(r.ax);
r.ax = 0x1800;
pw.adpcm_emulate = r.al;
ChipDatum cd = new ChipDatum(0x18, r.al, 0);
cd = new ChipDatum(0x18, r.al, 0);
ppz8em(cd);//.SetAdpcmEmu(r.al);//; ADPCMEmulate OFF
r.ax = r.stack.Pop();
cAtz_adchk_exit:;
}
pw.partWk[r.di].voicenum = r.al;

//IDE向け
cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = new MmlDatum(-1, enmMMLType.Instrument, pw.cmd.linePos
, (int)0xff
, (int)pw.partWk[r.di].voicenum
);
pmd.WriteDummy(cd);

ppz_neiro_reset:;
// push es
r.stack.Push(r.si);
Expand All @@ -757,7 +766,7 @@ private Func<object> comAtz()
r.al = pw.partb;
//push es
r.stack.Push(r.bx);
ChipDatum cd = new ChipDatum((r.al << 8) | 0x0e, ((r.dx << 16) | r.cx), ((r.di << 16) | r.si));
cd = new ChipDatum((r.al << 8) | 0x0e, ((r.dx << 16) | r.cx), ((r.di << 16) | r.si));
ppz8em(cd);//.SetLoopPoint(r.al, r.dx, r.cx, r.di, r.si);
r.bx = r.stack.Pop();
//pop es
Expand Down
Binary file modified PMDDotNETPlayer/lib/MDSound.dll
Binary file not shown.

0 comments on commit b9c8e49

Please sign in to comment.