diff --git a/CHANGE.txt b/CHANGE.txt index bda6dcd..179f15e 100644 --- a/CHANGE.txt +++ b/CHANGE.txt @@ -1,4 +1,7 @@ 更新履歴 +TAG049 2020/11/01 + Compiler/Driver:スキップ再生対応 + TAG048 2020/10/13 Driver:loop回数を取得できるようにした Player:-Lオプションが使用できるようになった diff --git a/PMDDotNETCompiler/compiler.cs b/PMDDotNETCompiler/compiler.cs index 25b6095..291684d 100644 --- a/PMDDotNETCompiler/compiler.cs +++ b/PMDDotNETCompiler/compiler.cs @@ -28,7 +28,7 @@ public class Compiler : iCompiler public voice_seg voice_seg = null; public byte[] outFFFileBuf { get; private set; } = null; public string outFFFileName { get; private set; } = null; - + public int skipIndex = -1;//繧ケ繧ュ繝繝嶺ス咲スョ //蜀驛ィ private string srcBuf = null; @@ -47,12 +47,12 @@ public Compiler(iEncoding enc = null) public void Init() { + this.isIDE = false; + this.skipPoint = Point.Empty; } public void SetCompileSwitch(params object[] param) { - this.isIDE = false; - this.skipPoint = Point.Empty; if (param == null) return; @@ -138,11 +138,18 @@ public MmlDatum[] Compile(Stream sourceMML, Func appendFileReade work.isIDE = isIDE; mc mc = new mc(this, mcArgs, srcBuf, ffBuf, work, env); + mc.skipPoint = this.skipPoint; MmlDatum[] ret = mc.compile_start(); memo_writeAddress = mc.memo_writeAddress; vdat_setAddress = mc.vdat_setAddress; mml_seg = mc.mml_seg; voice_seg = mc.voice_seg; + work.compilerInfo.jumpClock = -1; + if (mc.skipSW == 3) + { + skipIndex = mc.skipIndex + 1;//縺イ縺ィ縺、縺壹i縺 + work.compilerInfo.jumpClock = skipIndex; + } outFFFileBuf = null; if (mc.outVoiceBuf != null) { diff --git a/PMDDotNETCompiler/mc.cs b/PMDDotNETCompiler/mc.cs index e87b5c4..f37ba5f 100644 --- a/PMDDotNETCompiler/mc.cs +++ b/PMDDotNETCompiler/mc.cs @@ -1,5 +1,6 @@ サソusing System; using System.Collections.Generic; +using System.Drawing; using System.Text; using musicDriverInterface; using PMDDotNET.Common; @@ -22,8 +23,16 @@ public class mc //DotNET迢ャ閾ェ繝代Λ繝。繝シ繧ソ public byte[] outVoiceBuf = null;//髻ウ濶イ蜃コ蜉帷畑繝舌ャ繝輔ぃ(繝輔ぃ繧、繝ォ蜷阪ッv_filename) - public int memo_writeAddress { get; private set; } = -1; - public int vdat_setAddress { get; private set; } = -1; + public int memo_writeAddress = -1; + public int vdat_setAddress = -1; + public Point skipPoint = Point.Empty;//繧ケ繧ュ繝繝怜ヲ逅:mml荳翫ョ陦後→譯√r遉コ縺 + public int skipIndex = -1;//繧ケ繧ュ繝繝怜ヲ逅:m繝輔ぃ繧、繝ォ荳翫ョ菴咲スョ繧堤、コ縺 + public int skipSW = 0;//繧ケ繧ュ繝繝怜ヲ逅:騾イ謐励r遉コ縺 + //0 : mml荳翫ョ繧ケ繧ュ繝繝嶺ス咲スョ縺ョ陦後↓驕斐☆繧九ョ繧貞セ縺」縺ヲ縺繧狗憾諷 + //1 : mml荳翫ョ繧ケ繧ュ繝繝嶺ス咲スョ縺ョ譯√↓驕斐☆繧九ョ繧貞セ縺」縺ヲ縺繧狗憾諷 + //2 : 陦後→譯√′驕疲舌&繧後◆縺ョ縺ァ髻ウ遞九さ繝槭Φ繝峨′繧縺」縺ヲ縺上k縺ョ繧貞セ縺」縺ヲ縺繧狗憾諷 + //3 : 蜃ヲ逅螳御コ + public int skipPointCol = -1;//繧ケ繧ュ繝繝怜ヲ逅:譯√ョ菴咲スョ繧知ml荳翫ョ譁蟄玲焚縺ォ鄂ョ縺肴鋤縺医◆蛟、 @@ -1113,7 +1122,7 @@ 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(); @@ -1134,6 +1143,8 @@ private enmPass2JumpTable cloop() c_next:; + skipPointCol = work.si + skipPoint.X; + byte ah_b, al_b; char al = (work.si < mml_seg.mml_buf.Length ? mml_seg.mml_buf[work.si++] : (char)0x1a); if (al == 0x1a) @@ -3796,6 +3807,17 @@ private enmPass2JumpTable one_line_compile() , mml_seg.mml_filename , mml_seg.line , mml_seg.mml_buf.Substring(work.si, n - work.si))); + + //KUMA:繧ケ繧ュ繝繝怜ヲ逅シ壽欠螳壹&繧後◆陦後°繝√ぉ繝繧ッ縲ゅb縺励◎縺縺ェ繧峨√せ繧ュ繝繝怜ヲ逅縺ョ騾イ謐励r荳縺、荳翫£縺ヲ譯√メ繧ァ繝繧ッ迥カ諷九↓縺吶k縲 + if (!skipPoint.IsEmpty && skipSW == 0 && mml_seg.line == skipPoint.Y + 1) + { + skipSW = 1; + } + else if (skipSW == 1)//KUMA:蜷御ク陦後〒縲∝酔荳譯√↓縺ェ繧峨★縺ォ谺。縺ョ陦後↓遘サ縺」縺(縺、縺セ繧願。梧忰繧堤、コ縺励※縺縺溘j髻ウ遞九さ繝槭Φ繝峨′隕九▽縺九i縺ェ縺九▲縺)蝣エ蜷医ッ蠑キ蛻カ逧縺ォ谺。縺ョ繧ウ繝槭Φ繝峨↓繧ケ繧ュ繝繝励昴う繝ウ繝医r蜷ォ繧√k + { + skipSW = 2; + } + //#endif char al = (char)0; @@ -4031,6 +4053,12 @@ private enmPass2JumpTable skip_mml() //;============================================================================== private enmPass2JumpTable olc00() { + //KUMA:繧ケ繧ュ繝繝励@縺溘>譯√∪縺ァ遘サ蜍輔@縺ヲ縺縺溷エ蜷医ッ縲√せ繧ュ繝繝怜ヲ逅縺ョ騾イ謐励r縺イ縺ィ縺、縺ゅ£繧 + if (skipSW == 1 && skipPointCol <= work.si - 1) + { + skipSW = 2; + } + work.bx = 0;//offset comtbl // olc1: do @@ -4046,6 +4074,10 @@ private enmPass2JumpTable olc00() } } while (true); + //KUMA:繧ウ繝槭Φ繝峨ョ繧、繝ウ繝繝繧ッ繧ケ縺ィ譬シ邏阪い繝峨Ξ繧ケ繧剃ク譎ゆソ晏ュ + int bbx = work.bx; + int bdi = work.di; + byte dh = (byte)work.al; work.dx = (dh * 0x100) | (byte)work.dx; if (comtbl[work.bx].Item2 != null) @@ -4053,7 +4085,20 @@ private enmPass2JumpTable olc00() #if DEBUG Log.WriteLine(LogLevel.TRACE, string.Format("olc00:command:{0}", (char)dh)); #endif - return comtbl[work.bx].Item2(); + enmPass2JumpTable ret = comtbl[work.bx].Item2(); + + //KUMA:繧ケ繧ュ繝繝嶺ス咲スョ繧貞牡繧雁コ縺 + if (skipSW == 2) + { + //髻ウ髫弱さ繝槭Φ繝峨ョ縺ソ蟇セ雎。縺ィ縺吶k + if (bbx < 9) + { + skipIndex = bdi; + skipSW = 3; + } + } + + return ret; } throw new PMDDotNET.Common.PmdErrorExitException(string.Format("縺セ縺遘サ讀阪〒縺阪※縺ェ縺繧ウ繝槭Φ繝峨r讀懷コ縺励∪縺励◆({0})", (char)dh)); @@ -6120,7 +6165,6 @@ private enmPass2JumpTable bp9() work.al = (byte)mml_seg.leng; - List args = new List(); args.Add((mml_seg.octave << 4) | mml_seg.ontei); args.Add(mml_seg.leng); @@ -6564,7 +6608,13 @@ private void press() d = (byte)m_seg.m_buf.Get(work.di - 4).dat; if (ah != d) return; //prs1:; + + if (work.di - 1 == skipIndex) + { + skipIndex -= 3; + } work.di -= 3; + mml_seg.prsok |= 2;//蜉蟾・縺励◆flag d = (byte)m_seg.m_buf.Get(work.di).dat; @@ -6577,9 +6627,21 @@ private void press() m_seg.m_buf.Set(work.di, new MmlDatum(255)); work.al++;//255 over + + if (work.di - 1 == skipIndex) + { + skipIndex += 3; + } work.di += 3; + if (ah != 0xf) goto prs200; + + if (work.di - 1 == skipIndex) + { + skipIndex --; + } work.di--; + m_seg.m_buf.Set(work.di - 1, new MmlDatum(ah));//r&r -> rr 縺ォ螟画峩 prs200:; mml_seg.leng = work.al; @@ -6594,6 +6656,11 @@ private void press() if (d != 0xf) return; prs3:; + + if (work.di - 1 == skipIndex) + { + skipIndex -= 2; + } work.di -= 2; mml_seg.prsok |= 2;//蜉蟾・縺励◆flag @@ -6607,6 +6674,11 @@ private void press() m_seg.m_buf.Set(work.di, new MmlDatum(255)); work.al++;//255 over + + if (work.di - 1 == skipIndex) + { + skipIndex += 2; + } work.di += 2; goto prs200; } @@ -9655,10 +9727,10 @@ private void calc_line(ref int si) mml_seg.line = 1;//1陦檎岼縺九i ah++;//Include髫主ア、繧剃ク縺、蠅励d縺 bx = si + 1;//MML縺ョ繝輔ぃ繧、繝ォ蜷堺ス咲スョ繧達X縺ォ菫晏ュ - do - { - al = si < mml_seg.mml_buf.Length ? mml_seg.mml_buf[si++] : (char)0x1a; - } while (al != 0x0a);//繝輔ぃ繧、繝ォ蜷埼Κ蛻繧帝」帙ー縺 + //do + //{ + //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]; @@ -9684,23 +9756,26 @@ private void calc_line(ref int si) if (ah == 0) { si = dx;// Error菴咲スョ繧担I縺ォ謌サ縺 + mml_seg.mml_filename = mml_seg.currentMMLFile; return; } si = bx; - while (mml_seg.mml_buf[si] != 'e' && mml_seg.mml_buf[si] != 'E')//include繧偵せ繧ュ繝繝励☆繧 - { - si++; - } - si++; - - mml_seg.mml_filename = ""; //offset mml_filename - do - { - mml_seg.mml_filename += mml_seg.mml_buf[si++];//Include荳ュ縺ォError --> MML Filename繧貞、画峩 - } while (si != mml_seg.mml_buf.Length && mml_seg.mml_buf[si] >= 0x20); - si = dx;// Error菴咲スョ繧担I縺ォ謌サ縺 - mml_seg.mml_filename = mml_seg.mml_filename.Trim(); + mml_seg.mml_filename = mml_seg.currentMMLFile; + + //while (mml_seg.mml_buf[si] != 'e' && mml_seg.mml_buf[si] != 'E')//include繧偵せ繧ュ繝繝励☆繧 + //{ + // si++; + //} + //si++; + + //mml_seg.mml_filename = ""; //offset mml_filename + //do + //{ + // mml_seg.mml_filename += mml_seg.mml_buf[si++];//Include荳ュ縺ォError --> MML Filename繧貞、画峩 + //} while (si != mml_seg.mml_buf.Length && mml_seg.mml_buf[si] >= 0x20); + //si = dx;// Error菴咲スョ繧担I縺ォ謌サ縺 + //mml_seg.mml_filename = mml_seg.mml_filename.Trim(); } diff --git a/PMDDotNETCompiler/mml_seg.cs b/PMDDotNETCompiler/mml_seg.cs index 6a0819f..2bb1431 100644 --- a/PMDDotNETCompiler/mml_seg.cs +++ b/PMDDotNETCompiler/mml_seg.cs @@ -355,10 +355,11 @@ public class mml_seg public int includeFileHistoryPos; public string currentMMLFile; public Stack includeFileHistoryStack = new Stack(); - //public Stack includeFileLineStack = new Stack(); - //mml_seg ends + //public Stack includeFileLineStack = new Stack(); + //mml_seg ends - } + + } } diff --git a/PMDDotNETConsole/Program.cs b/PMDDotNETConsole/Program.cs index fa6f8a3..76e6ce4 100644 --- a/PMDDotNETConsole/Program.cs +++ b/PMDDotNETConsole/Program.cs @@ -97,8 +97,11 @@ private static void Compile(string[] args,int argIndex) ffFileBuf = File.ReadAllBytes(ffFile); compiler.SetFfFileBuf(ffFileBuf); } + +#if DEBUG //compiler.SetCompileSwitch("IDE"); - //compiler.SetCompileSwitch("SkipPoint=R19:C30"); + //compiler.SetCompileSwitch("SkipPoint=R60:C13"); +#endif if (!isXml) { diff --git a/PMDDotNETConsole/Properties/launchSettings.json b/PMDDotNETConsole/Properties/launchSettings.json index 0fce5e3..6866c1a 100644 --- a/PMDDotNETConsole/Properties/launchSettings.json +++ b/PMDDotNETConsole/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "PMDDotNETConsole": { "commandName": "Project", - "commandLineArgs": "-LOGLEVEL=DEBUG -XML /V /c C:\\Users\\kuma\\Desktop\\pmd\\fromTAN-Y\\testTH_01.mml" + "commandLineArgs": "-LOGLEVEL=DEBUG /V /c D:\\bootcamp\\FM髻ウ貅申\player\\pmd\\fromTAN-Y\\testORANGE04.MML" } } } \ No newline at end of file diff --git a/PMDDotNETDriver/PCMDRV.cs b/PMDDotNETDriver/PCMDRV.cs index 7326ada..6a52c4d 100644 --- a/PMDDotNETDriver/PCMDRV.cs +++ b/PMDDotNETDriver/PCMDRV.cs @@ -39,6 +39,8 @@ public void pcmmain() if (r.si == 0) return;// goto pcmmain_ret; + if (r.si == pw.jumpIndex) pw.jumpIndex = -1;//KUMA:Added + Func ret = null; if (pw.partWk[r.di].partmask != 0) ret = pcmmain_nonplay; @@ -85,7 +87,13 @@ private Func mp1m0() { do { - r.al = (byte)pw.md[r.si++].dat; + r.al = (byte)pw.md[r.si].dat; + + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + + r.si++; + if (r.al < 0x80) goto mp2m; if (r.al == 0x80) goto mp15m; diff --git a/PMDDotNETDriver/PCMDRV86.cs b/PMDDotNETDriver/PCMDRV86.cs index 6f91c93..0cf2a62 100644 --- a/PMDDotNETDriver/PCMDRV86.cs +++ b/PMDDotNETDriver/PCMDRV86.cs @@ -94,7 +94,12 @@ private Func mp1m0() { do { - r.al = (byte)pw.md[r.si++].dat; + r.al = (byte)pw.md[r.si].dat; + + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + + r.si++; if (r.al < 0x80) goto mp2m; if (r.al == 0x80) goto mp15m; diff --git a/PMDDotNETDriver/PMD.cs b/PMDDotNETDriver/PMD.cs index 05a4eb1..ff9834d 100644 --- a/PMDDotNETDriver/PMD.cs +++ b/PMDDotNETDriver/PMD.cs @@ -86,15 +86,19 @@ public void Rendering() lock (pw.SystemInterrupt) { - pw.timer.timer(); - pw.timeCounter++; - if ((pw.timer.StatReg & 3) != 0) + do { - lock (r.lockobj) + pw.timer.timer(); + pw.timeCounter++; + if ((pw.timer.StatReg & 3) != 0) { - FM_Timer_main(); + lock (r.lockobj) + { + FM_Timer_main(); + } } - } + } while (pw.jumpIndex != -1 && pw.nowLoopCounter<1); + //work.SystemInterrupt = false; } } @@ -1123,7 +1127,7 @@ private void mmain() mmain_exit:; - Console.WriteLine("loop counter:{0}", pw.nowLoopCounter); + //Console.WriteLine("loop counter:{0}", pw.nowLoopCounter); @@ -1255,6 +1259,8 @@ private Func mp10() do { pw.cmd = pw.md[r.si]; + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added r.al = (byte)pw.md[r.si++].dat; if (r.al < 0x80) @@ -1610,6 +1616,8 @@ private void psgmain() r.si = (ushort)pw.partWk[pw.part_data_table[r.di]].address; //; si = PART DATA ADDRESS if (r.si == 0) return; + if (r.si == pw.jumpIndex) pw.jumpIndex = -1;//KUMA:Added + Func ret = null; if (pw.partWk[r.di].partmask != 0) ret = psgmain_nonplay; @@ -1656,6 +1664,10 @@ private Func psgmain_c_1() private Func mp1p()//; DATA READ { pw.cmd = pw.md[r.si]; + + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + r.al = (byte)pw.md[r.si++].dat; if (r.al < 0x80) return mp2p; if (r.al == 0x80) return mp15p; @@ -1927,6 +1939,8 @@ private void rhythmmain() r.si = (ushort)pw.partWk[pw.part_data_table[r.di]].address; //; si = PART DATA ADDRESS if (r.si == 0) return; + if (r.si == pw.jumpIndex) pw.jumpIndex = -1;//KUMA:Added + //; 髻ウ髟キ -1 pw.partWk[r.di].leng--; if (pw.partWk[r.di].leng != 0) @@ -1965,6 +1979,10 @@ private void rhyms00() private void rlnset() { r.al = (byte)pw.rd[r.bx].dat;// mov al,[bx] + + if (r.bx == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + r.bx++; pw.rhyadr = r.bx; @@ -1989,7 +2007,13 @@ private void reom() reom:; do { - r.al = (byte)pw.md[r.si++].dat; + r.al = (byte)pw.md[r.si].dat; + + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + + r.si++; + if (r.al == 0x80) goto rfin; if (r.al < 0x80) break; diff --git a/PMDDotNETDriver/PMDDotNETOption.cs b/PMDDotNETDriver/PMDDotNETOption.cs index 42e953e..9239ff3 100644 --- a/PMDDotNETDriver/PMDDotNETOption.cs +++ b/PMDDotNETDriver/PMDDotNETOption.cs @@ -18,5 +18,6 @@ public class PMDDotNETOption public string[] envPmdOpt; public string srcFile; public string PPCHeader; + public int jumpIndex; } } diff --git a/PMDDotNETDriver/PPZDRV.cs b/PMDDotNETDriver/PPZDRV.cs index d68d1af..fd6776e 100644 --- a/PMDDotNETDriver/PPZDRV.cs +++ b/PMDDotNETDriver/PPZDRV.cs @@ -53,6 +53,10 @@ public void ppzmain() if (r.si == 0) return;// goto pcmmain_ret; + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + //Console.WriteLine("{0}", r.si); + Func ret = null; if (pw.partWk[r.di].partmask != 0) ret = ppzmain_nonplay; @@ -100,6 +104,10 @@ private Func mp1z0() do { pw.cmd = pw.md[r.si]; + + if (r.si == pw.jumpIndex) + pw.jumpIndex = -1;//KUMA:Added + r.al = (byte)pw.md[r.si++].dat; if (r.al < 0x80) goto mp2z; if (r.al == 0x80) goto mp15z; diff --git a/PMDDotNETDriver/PW.cs b/PMDDotNETDriver/PW.cs index 73699f8..e9ca359 100644 --- a/PMDDotNETDriver/PW.cs +++ b/PMDDotNETDriver/PW.cs @@ -1054,6 +1054,9 @@ public void Clear() , 0x0f1a5//;11 b }; + //pmdDotNET 迢ャ閾ェ + public int jumpIndex = -1; + public PW() @@ -1226,6 +1229,9 @@ public void SetOption(PMDDotNETOption dop, string[] op) { pmdOption = op; + jumpIndex = dop.jumpIndex; + //Console.WriteLine("{0}", jumpIndex); + if (dop.isAUTO) { dop.usePPS = !string.IsNullOrEmpty(ppsFile); diff --git a/PMDDotNETDriver/driver.cs b/PMDDotNETDriver/driver.cs index e343517..cc4d295 100644 --- a/PMDDotNETDriver/driver.cs +++ b/PMDDotNETDriver/driver.cs @@ -299,13 +299,21 @@ public void Init(string fileName, Action opnaWrite, Action envPmd = (string[])pdnos[8], envPmdOpt = (string[])pdnos[9], srcFile = (string)pdnos[10], - PPCHeader = (string)pdnos[11] + PPCHeader = (string)pdnos[11], + jumpIndex = -1 }; Func appendFileReaderCallback = (pdnos.Length < 13 || pdnos[12] == null) ? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName)) : (Func)pdnos[12]; + + if (pdnos.Length == 14) + { + pdno.jumpIndex = (int)pdnos[13]; + } + + string[] po = (string[])option[1]; Func ppz8Write = (Func)option[2]; Func ppsdrvWrite = (Func)option[3]; diff --git a/PMDDotNETPlayer/PMDDotNETPlayer.csproj.user b/PMDDotNETPlayer/PMDDotNETPlayer.csproj.user index db7f14d..588f8a1 100644 --- a/PMDDotNETPlayer/PMDDotNETPlayer.csproj.user +++ b/PMDDotNETPlayer/PMDDotNETPlayer.csproj.user @@ -1,7 +1,7 @@ サソ - -D=EMU -L=2 "D:\bootcamp\FM髻ウ貅申player\pmd\testCOCO_OP.m" + -D=EMU -L=2 "D:\bootcamp\FM髻ウ貅申player\pmd\fromTAN-Y\testORANGE04.M" -D=GIMIC C:\Users\kuma\Desktop\desire\des_26.m diff --git a/PMDDotNETPlayer/Program.cs b/PMDDotNETPlayer/Program.cs index 3b944d0..28b9bce 100644 --- a/PMDDotNETPlayer/Program.cs +++ b/PMDDotNETPlayer/Program.cs @@ -255,6 +255,7 @@ static int Main(string[] args) //dop.ppsdrv = ppsdrv; dop.envPmd = envPmd; dop.srcFile = srcFile; + dop.jumpIndex = -1;// 112;// -1; List pop = new List(); bool pmdvolFound = false; for(int i = 0; i < opt.Count; i++) diff --git a/lib/musicDriverInterface.dll b/lib/musicDriverInterface.dll index 98badd0..c233345 100644 Binary files a/lib/musicDriverInterface.dll and b/lib/musicDriverInterface.dll differ