Skip to content

Commit

Permalink
TAG037 2020/08/26
Browse files Browse the repository at this point in the history
  他アプリとの連携のための微調整
  • Loading branch information
kumatan committed Aug 26, 2020
1 parent 4bf9616 commit f4a232d
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 13 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����
TAG037 2020/08/26
���A�v���Ƃ̘A�g�̂��߂̔�����

TAG036 2020/08/21
���A�v���Ƃ̘A�g�̂��߂̔�����

Expand Down
11 changes: 11 additions & 0 deletions PMDDotNETCompiler/compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public MmlDatum[] Compile(Stream sourceMML, Func<string, Stream> appendFileReade
}
}

//Console.WriteLine(srcBuf);

this.appendFileReaderCallback = appendFileReaderCallback;

try
Expand All @@ -141,6 +143,15 @@ public MmlDatum[] Compile(Stream sourceMML, Func<string, Stream> appendFileReade
outFFFileName= voice_seg.v_filename;
}

//foreach (MmlDatum d in ret)
//{
// if (d.type == enmMMLType.Note)
// {
// Console.WriteLine("{0} {1}", d.linePos.row, d.linePos.col);
// ;
// }
//}

return ret;

}
Expand Down
78 changes: 72 additions & 6 deletions PMDDotNETCompiler/mc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ private enmPass2JumpTable Pass2CompileStart()

mml_seg.part = 1;
mml_seg.pass = 1;
mml_seg.chipCh = 0;

return enmPass2JumpTable.cmloop;
}
Expand All @@ -827,6 +828,7 @@ private enmPass2JumpTable Pass2CompileStart()
private enmPass2JumpTable cmloop()
{
#if !efc

int al = mml_seg.opl_flg;
al |= mml_seg.x68_flg;
if (al != 0)
Expand Down Expand Up @@ -893,6 +895,7 @@ private enmPass2JumpTable part_stadr_set()
private enmPass2JumpTable cmloop2()
{
work.si = 0;//offset mml_buf
Log.WriteLine(LogLevel.DEBUG, string.Format("chipCh:{0}", mml_seg.chipCh));
cm_init();

byte ah, al;
Expand Down Expand Up @@ -1244,6 +1247,9 @@ private enmPass2JumpTable check_lopcnt()
//; PART INC. & LOOP
//;==============================================================================
mml_seg.part++;
mml_seg.chipCh++;
if (mml_seg.chipCh == 6) mml_seg.chipCh += 3;
if (mml_seg.chipCh == 12) mml_seg.chipCh += 6;
#if efc
if (mml_seg.part < mml_seg.max_part + 2) goto cmloop;
#else
Expand Down Expand Up @@ -1276,14 +1282,17 @@ private enmPass2JumpTable check_lopcnt()

al = (byte)mml_seg.fm3_partchr1;
mml_seg.fm3_partchr1 = 0;
mml_seg.chipCh = 6;
if (al != 0) goto fm3c_main;

al = (byte)mml_seg.fm3_partchr2;
mml_seg.fm3_partchr2 = 0;
mml_seg.chipCh = 7;
if (al != 0) goto fm3c_main;

al = (byte)mml_seg.fm3_partchr3;
mml_seg.fm3_partchr3 = 0;
mml_seg.chipCh = 8;
if (al == 0) goto pcm_check;

fm3c_main:;
Expand Down Expand Up @@ -3753,15 +3762,15 @@ private void get_param()
private enmPass2JumpTable one_line_compile()
{

#if DEBUG
//#if DEBUG
int n = mml_seg.mml_buf.IndexOf("\r\n", work.si);
int r = work.si;
calc_line(ref r);
Log.WriteLine(LogLevel.DEBUG, string.Format("{0}({1}) \t{2}"
, System.IO.Path.GetFileName(mml_seg.mml_filename)
, mml_seg.mml_filename
, mml_seg.line
, mml_seg.mml_buf.Substring(work.si, n - work.si)));
#endif
//#endif

char al = (char)0;
do
Expand Down Expand Up @@ -3819,6 +3828,7 @@ private enmPass2JumpTable olc03()
{
do
{
mml_seg.stPos = work.si;
char ch = work.si < mml_seg.mml_buf.Length ? mml_seg.mml_buf[work.si++] : (char)0x1a;
if (ch == ' ') continue;
work.al = (byte)ch;
Expand Down Expand Up @@ -4447,7 +4457,10 @@ private enmPass2JumpTable porta_start()
error('{', 9, work.si);
}

m_seg.m_buf.Set(work.di++, new MmlDatum(0xda));
MmlDatum md = new MmlDatum(0xda);
md.linePos = new LinePos();
md.linePos.col = Math.Max(work.si - mml_seg.linehead , 1);
m_seg.m_buf.Set(work.di++, md);
mml_seg.porta_flag = 1;

//; 分散和音開始アドレスをセット 4.8r
Expand Down Expand Up @@ -4498,6 +4511,16 @@ private enmPass2JumpTable porta_end()
error('}', 15, work.si);
}

MmlDatum srcMd = m_seg.m_buf.Get(work.di - 4);
MmlDatum dstMd = m_seg.m_buf.Get(work.di - 5);
dstMd.args = srcMd.args;
LinePos lp = dstMd.linePos;
dstMd.linePos = srcMd.linePos;
dstMd.linePos.col = lp.col;
dstMd.linePos.length = Math.Max(work.si - mml_seg.linehead + 1, 1) - lp.col;
dstMd.type = srcMd.type;
srcMd.linePos = null;

work.al = (byte)m_seg.m_buf.Get(work.di - 2).dat;
m_seg.m_buf.Set(work.di - 3, new MmlDatum(work.al));

Expand Down Expand Up @@ -4530,7 +4553,7 @@ private enmPass2JumpTable porta_end()
lngcal();
cy = futen();
cch = (byte)m_seg.m_buf.Get(work.di - 1).dat;
if (al >= cch)
if (al >= cch)//KUMA:ディレイ値が指定音長よりも長い場合はエラー
{
error('}', 8, work.si);
}
Expand Down Expand Up @@ -5946,7 +5969,8 @@ private enmPass2JumpTable ots002()
if (work.bx == mml_seg.alldet) goto bp7;
if (mml_seg.porta_flag == 1) goto porta_pitchset;
work.al = 0xfa;
m_seg.m_buf.Set(work.di++, new MmlDatum(work.al));

m_seg.m_buf.Set(work.di++, new MmlDatum((byte)work.al));
m_seg.m_buf.Set(work.di++, new MmlDatum((byte)work.bx));
m_seg.m_buf.Set(work.di++, new MmlDatum((byte)(work.bx >> 8)));

Expand Down Expand Up @@ -5996,6 +6020,9 @@ private enmPass2JumpTable rest()
private enmPass2JumpTable otoset_x()
{
work.bx = (work.bx & 0xff00) + (byte)work.al;

mml_seg.ontei = work.al;

return bp8();
}

Expand Down Expand Up @@ -6063,8 +6090,47 @@ private enmPass2JumpTable bp9()
//;==============================================================================
//; 音長 DATA SET
//;==============================================================================

work.al = (byte)mml_seg.leng;


List<object> args = new List<object>();
args.Add((mml_seg.octave << 4) | mml_seg.ontei);
args.Add(mml_seg.leng);
int p = work.si - 1;
while (mml_seg.mml_buf[p] == ' ' || mml_seg.mml_buf[p] == '\t') p--;
p++;
LinePos lp = new LinePos(
mml_seg.mml_filename
, Math.Max(mml_seg.line, 1)
, Math.Max(mml_seg.stPos - mml_seg.linehead + 1, 1)
, p - mml_seg.stPos
, mml_seg.chipCh < 6
? "FM"
: (mml_seg.chipCh >= 6 && mml_seg.chipCh <= 8
? "FM3ex"
: (mml_seg.chipCh >= 9 && mml_seg.chipCh <= 11
? "SSG"
: (mml_seg.chipCh == 18
? "ADPCM"
: "PPZ8"
)
)
)
, mml_seg.chipCh < 20 ? "YM2608" : "PPZ8"
, 0
, 0
, mml_seg.chipCh - (mml_seg.chipCh < 20 ? 0 : 20)
);
MmlDatum dmy= m_seg.m_buf.Get(work.di - 1);
dmy.type = enmMMLType.Note;
dmy.args = args;
dmy.linePos = lp;


m_seg.m_buf.Set(work.di++, new MmlDatum(work.al));

//m_seg.m_buf.Set(work.di++, new MmlDatum(work.al));
mml_seg.prsok |= 1;// 音長flagをset
mml_seg.prsok &= 0xf3;//音長+タイ,ポルタflagをreset

Expand Down
7 changes: 5 additions & 2 deletions PMDDotNETCompiler/mml_seg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,12 @@ public class mml_seg
public byte mmlbuf_end;//b

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

//mml_seg ends
//mml_seg ends


}
}
}
2 changes: 1 addition & 1 deletion PMDDotNETConsole/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"PMDDotNETConsole": {
"commandName": "Project",
"commandLineArgs": "-LOGLEVEL=DEBUG /vw /c C:\\Users\\kuma\\Desktop\\pmd\\work.MML"
"commandLineArgs": "-LOGLEVEL=DEBUG /V /c C:\\Users\\kuma\\Desktop\\pmd\\fromTAN-Y\\testHATUNE27.MML"
}
}
}
25 changes: 23 additions & 2 deletions PMDDotNETDriver/PMD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class PMD
private Func<ChipDatum,int> ppz8em = null;
private Func<ChipDatum, int> ppsdrv = null;
public PCMLOAD pcmload = null;
private Action<ChipDatum> WriteOPNARegister = null;


public PMD(
Expand Down Expand Up @@ -55,7 +56,7 @@ public PMD(
pw.fm2_port2 = 0x18e;//データ(拡張)

r = new x86Register();
pc98 = new Pc98(WriteOPNARegister);
pc98 = new Pc98(WriteOPNARegister, pw);
pcmload = new PCMLOAD(this, pw, r, pc98, ppz8em, ppsdrv, appendFileReaderCallback);

ppzdrv = new PPZDRV(this, pw, r, pc98, ppz8em, pcmload.ppzPcmData);
Expand All @@ -64,6 +65,7 @@ public PMD(
ppzdrv.init();
pcmdrv86 = new PCMDRV86();
efcdrv = new EFCDRV(this, pw, r, ppsdrv);
this.WriteOPNARegister = WriteOPNARegister;

Set_int60_jumptable();
Set_n_int60_jumptable();
Expand Down Expand Up @@ -1196,8 +1198,10 @@ private Func<object> mp10()
{
do
{
pw.cmd = pw.md[r.si];
r.al = (byte)pw.md[r.si++].dat;
if (r.al < 0x80) goto mp2;
if (r.al < 0x80)
goto mp2;
if (r.al == 0x80) goto mp15;

//; ELSE COMMANDS
Expand Down Expand Up @@ -1231,6 +1235,10 @@ private Func<object> mp10()
oshift();
fnumset();

ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = pw.cmd;
WriteOPNARegister(cd);

r.al = (byte)pw.md[r.si++].dat;
pw.partWk[r.di].leng = r.al;
calc_q();
Expand Down Expand Up @@ -1588,6 +1596,7 @@ private Func<object> psgmain_c_1()

private Func<object> mp1p()//; DATA READ
{
pw.cmd = pw.md[r.si];
r.al = (byte)pw.md[r.si++].dat;
if (r.al < 0x80) return mp2p;
if (r.al == 0x80) return mp15p;
Expand Down Expand Up @@ -1628,6 +1637,10 @@ private Func<object> mp15p()
oshiftp();
fnumsetp();

ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = pw.cmd;
WriteOPNARegister(cd);

r.al = (byte)pw.md[r.si++].dat;
pw.partWk[r.di].leng = r.al;
calc_q();
Expand Down Expand Up @@ -4073,6 +4086,10 @@ private Func<object> porta()
if (pw.partWk[r.di].partmask != 0)
goto porta_notset;

ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = pw.cmd;
WriteOPNARegister(cd);

r.al = (byte)pw.md[r.si++].dat;
lfoinit();
oshift();
Expand Down Expand Up @@ -4147,6 +4164,10 @@ private Func<object> portap()
//return porta_notset;
}

ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = pw.cmd;
WriteOPNARegister(cd);

r.al = (byte)pw.md[r.si++].dat;
lfoinitp();
oshiftp();
Expand Down
11 changes: 11 additions & 0 deletions PMDDotNETDriver/PPZDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private Func<object> mp1z0()
{
do
{
pw.cmd = pw.md[r.si];
r.al = (byte)pw.md[r.si++].dat;
if (r.al < 0x80) goto mp2z;
if (r.al == 0x80) goto mp15z;
Expand Down Expand Up @@ -134,6 +135,10 @@ private Func<object> mp1z0()
pmd.oshift();
fnumsetz();

ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = pw.cmd;
ppz8em(cd);

r.al = (byte)pw.md[r.si++].dat;
pw.partWk[r.di].leng = r.al;
pmd.calc_q();
Expand Down Expand Up @@ -469,6 +474,7 @@ private Func<object> ppz_mml_part_mask()
}
r.ah = 2;
ChipDatum cd = new ChipDatum(0x02, r.al, 0);
cd.addtionalData = pw.cmd;
ppz8em(cd);//.StopPCM(r.al);

pmpz_ret:;
Expand Down Expand Up @@ -579,6 +585,10 @@ private Func<object> portaz()
return null;
}

ChipDatum cd = new ChipDatum(-1, -1, -1);
cd.addtionalData = pw.cmd;
ppz8em(cd);

//pop ax; commandsp
r.al = (byte)pw.md[r.si++].dat;
pmd.lfoinitp();
Expand Down Expand Up @@ -895,6 +905,7 @@ private void volsetz()
r.ah = 0x02;
r.al = pw.partb;
cd = new ChipDatum(0x02, r.al, 0);
cd.addtionalData = pw.cmd;
ppz8em(cd);//.StopPCM(r.al);// ; volume = 0... keyoff
return;
}
Expand Down
1 change: 1 addition & 0 deletions PMDDotNETDriver/PW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,7 @@ private MmlDatum[] MakeMmlDatum(byte[] dd)
, 24,221, 1, 0, 55, 16, 16, 39, 0, 0, 0
, 0xff//-1
};
internal MmlDatum cmd;
#endregion

}
Expand Down
Loading

0 comments on commit f4a232d

Please sign in to comment.