Skip to content

Commit

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

TAG037 2020/08/26
���A�v���Ƃ̘A�g�̂��߂̔�����

Expand Down
3 changes: 1 addition & 2 deletions PMDDotNETCompiler/compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ public bool Compile(Stream sourceMML, Stream destCompiledBin, Func<string, Strea

public CompilerInfo GetCompilerInfo()
{
CompilerInfo ci = new CompilerInfo();
return ci;
return work.compilerInfo;
}

public Tuple<string, string>[] GetTags(string srcBuf, Func<string, Stream> appendFileReaderCallback)
Expand Down
63 changes: 52 additions & 11 deletions PMDDotNETCompiler/lc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ private enmPart_ends check_j()
//;==============================================================================
private enmPart_ends com_loop()
{

Log.WriteLine(LogLevel.DEBUG, string.Format("partType:{0} partCh:{1} partNum:{2}", part_type, part_chr, part_num));

do
{
byte al;
Expand All @@ -179,7 +182,7 @@ private enmPart_ends com_loop()
#if DEBUG
Log.WriteLine(LogLevel.TRACE, string.Format("si:{0}", work.si));
#endif
al = (byte)(work.si<m_seg.m_buf.Count ? m_seg.m_buf.Get(work.si++).dat : 0x80);
al = (byte)(work.si < m_seg.m_buf.Count ? m_seg.m_buf.Get(work.si++).dat : 0x80);

if (al == 0x80) return enmPart_ends.part_ends;
if (al >= 0x80) break;
Expand Down Expand Up @@ -210,6 +213,7 @@ private enmPart_ends part_ends()
print_length();

part_chr++;
part_num++;
if (part_chr < 'K') return enmPart_ends.part_loop;

int di = work.di;
Expand All @@ -224,6 +228,8 @@ private enmPart_ends part_ends()
work.si += 0;//offset m_buf
char al_c = bx < 3 ? _fm3_partchr[bx] : _pcm_partchr[bx - 3];
part_chr = al_c;
part_num = bx < 3 ? bx : (bx - 3);
part_type = bx < 3 ? "FM3ex" : "PPZ8";
if (work.di < 3) fm3_adr[work.di] = 0;
else pcm_adr[work.di - 3] = 0;

Expand Down Expand Up @@ -454,7 +460,7 @@ private void loop_set()
private void loop_start()
{
int ax = (byte)m_seg.m_buf.Get(work.si++).dat;
ax += m_seg.m_buf.Get(work.si++).dat*0x100;
ax += m_seg.m_buf.Get(work.si++).dat * 0x100;

work.bx = ax;
work.bx += 1;//offset m_buf+1
Expand Down Expand Up @@ -523,7 +529,7 @@ private void special_0c0h()
al = (byte)~al;
al += 0;//offset jumptable_0c0h
jumptable_0c0h[al]();
spc0_ret:;
spc0_ret:;
}


Expand All @@ -534,39 +540,72 @@ private void special_0c0h()
//;==============================================================================
private void print_length()
{
int tc = 0;
int lc = 0;

if (all_length == 0) return;// データ無し
string msg = part_mes+part_chr+ part_chr_n;
string msg = part_mes + part_chr + part_chr_n;

int ax = all_length & 0xffff;
int dx = (all_length >> 16) & 0xffff;
int bx = max_all & 0xffff;
int cx = (max_all>>16) & 0xffff;
int cx = (max_all >> 16) & 0xffff;
if (max_all - all_length < 0)
{
max_all = all_length;// ax | dx * 0x10000;
}
//not_over_all:;
msg += string.Format("{0}", ax);
tc = ax;

if (loop_flag != 1) goto pe_loop;
if(print_flag!=0) mc.print_mes(loop_mes2);
if (print_flag != 0)
{
mc.print_mes(loop_mes2);
}

work.compilerInfo.partName.Add(part_chr.ToString());
work.compilerInfo.totalCount.Add(tc);
work.compilerInfo.loopCount.Add(lc);

return;
pe_loop:;
dx = (loop_length >> 16) & 0xffff;
ax = loop_length & 0xffff;
ax++;
if (loop_length+1 == 0) goto pe_00;
if (loop_length + 1 == 0) goto pe_00;
msg += loop_mes;

//mc.print_mes(loop_mes);
int n = all_length - loop_length;
if (max_loop<n)
if (max_loop < n)
{
max_loop = n;
}
//not_over_loop:;
msg += string.Format("{0}", n);
lc = n;

pe_00:;
if (print_flag != 0) mc.print_mes(msg);
if (print_flag != 0)
{
mc.print_mes(msg);

if (work.compilerInfo.partType == null) work.compilerInfo.partType = new List<string>();
work.compilerInfo.partType.Add(part_type);

if (work.compilerInfo.partNumber == null) work.compilerInfo.partNumber = new List<int>();
work.compilerInfo.partNumber.Add(part_num);

if (work.compilerInfo.partName == null) work.compilerInfo.partName = new List<string>();
work.compilerInfo.partName.Add(part_chr.ToString());

if (work.compilerInfo.totalCount == null) work.compilerInfo.totalCount = new List<int>();
work.compilerInfo.totalCount.Add(tc);

if (work.compilerInfo.loopCount == null) work.compilerInfo.loopCount = new List<int>();
work.compilerInfo.loopCount.Add(lc);
}
//mc.print_mes(_crlf_mes);
//pe_01:;
}
Expand Down Expand Up @@ -677,7 +716,9 @@ private void setJumpTable()


public string part_mes = "Part ";
public string part_type = "YM2608";
public char part_chr = ' ';
public int part_num = 0;
private string part_chr_n = "\tLength : ";
private string loop_mes = "\t/ Loop : ";
private string loop_mes2 = "\t/ Found Infinite Local Loop!";
Expand All @@ -700,7 +741,7 @@ private void setJumpTable()
(char)0
};

public char[] _pcm_partchr = new char[8]
public char[] _pcm_partchr = new char[8]
{
(char)0,
(char)0,
Expand All @@ -713,4 +754,4 @@ private void setJumpTable()
};

}
}
}
1 change: 1 addition & 0 deletions PMDDotNETCompiler/m_seg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class m_seg
public byte m_start;//b
public AutoExtendList<MmlDatum> m_buf = new AutoExtendList<MmlDatum>();//[63 * 1024 - 2];
public byte mbuf_end;
public List<Tuple<int, MmlDatum>> dummy = new List<Tuple<int, MmlDatum>>();
#endif
}
}
68 changes: 42 additions & 26 deletions PMDDotNETCompiler/mc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,13 +1315,15 @@ private enmPass2JumpTable check_lopcnt()
if (mml_seg.pcm_ofsadr == 0) goto rt;// 無し

bx = 0;//offset pcm_partchr1
mml_seg.chipCh = -1;

//pcmc_loop:;
for (int cx = 0; cx < 8; cx++)
{
al = (byte)mml_seg.pcm_partchr[bx];
mml_seg.pcm_partchr[bx] = (char)0;
bx++;
mml_seg.chipCh++;
if (al != 0) goto pcmc_main;
}

Expand Down Expand Up @@ -5901,6 +5903,7 @@ private enmPass2JumpTable ots000()
bh = (byte)(bh << 4);
bl |= bh;// bl=音階 DATA //KUMA: 上位4bit:オクターブ 下位4bit:音階
work.bx = bh * 0x100 + bl;
mml_seg.ontei = work.al;

return enmPass2JumpTable.ots002;
}
Expand Down Expand Up @@ -6097,32 +6100,8 @@ private enmPass2JumpTable bp9()
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);
LinePos lp = MakeLinePos();
MmlDatum dmy = m_seg.m_buf.Get(work.di - 1);
dmy.type = enmMMLType.Note;
dmy.args = args;
dmy.linePos = lp;
Expand Down Expand Up @@ -6156,6 +6135,39 @@ private enmPass2JumpTable bp9()
return bp10();
}

private LinePos MakeLinePos()
{
int p = work.si - 1;
while (mml_seg.mml_buf[p] == ' ' || mml_seg.mml_buf[p] == '\t') p--;
p++;

return 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.ongen == mml_seg.pcm_ex
? "PPZ8"
: (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"
: ""
)
)
)
)
, mml_seg.ongen != mml_seg.pcm_ex ? "YM2608" : "PPZ8"
, 0
, 0
, mml_seg.chipCh - (mml_seg.chipCh < 20 ? 0 : 20)
);
}

private enmPass2JumpTable bp10()
{
mml_seg.tie_flag = 0;
Expand Down Expand Up @@ -7275,11 +7287,15 @@ private enmPass2JumpTable vseta()

bool cy = lngset(out int bx, out byte alb);
work.bx = bx;

m_seg.dummy.Add(new Tuple<int, MmlDatum>(work.di, new MmlDatum(-1, enmMMLType.Volume, MakeLinePos(), bx)));

work.bx += mml_seg.volss2;
if ((byte)work.bx >= 17)
{
error('v', 2, work.si);
}

#if !efc
if (mml_seg.part == mml_seg.pcmpart) return enmPass2JumpTable.vsetm;
if (mml_seg.ongen == mml_seg.pcm_ex) return enmPass2JumpTable.vsetm;
Expand Down
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 /V /c C:\\Users\\kuma\\Desktop\\pmd\\fromTAN-Y\\testHATUNE27.MML"
"commandLineArgs": "-LOGLEVEL=DEBUG -XML /V /c C:\\Users\\kuma\\Desktop\\pmd\\fromTAN-Y\\testTH_01.MML"
}
}
}
2 changes: 1 addition & 1 deletion PMDDotNETDriver/driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public void Init(
{
MmlDatum[] s = (MmlDatum[])serializer.Deserialize(sr);
Init(s, opnaWrite, opnaWaitSend, addtionalPMDDotNETOption, addtionalPMDOption
, appendFileReaderCallback
, appendFileReaderCallback ?? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName))
, ppz8Write
, ppsdrvWrite
);
Expand Down
2 changes: 1 addition & 1 deletion PMDDotNETPlayer/PMDDotNETPlayer.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>-D=EMU -B=auto C:\Users\kuma\Desktop\pmd\fromTAN-Y\testHATUNE27.MZ</StartArguments>
<StartArguments>-D=EMU -B=auto C:\Users\kuma\Desktop\pmd\fromTAN-Y\testTH_01.xml</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartArguments>-D=GIMIC C:\Users\kuma\Desktop\desire\des_26.m</StartArguments>
Expand Down
4 changes: 3 additions & 1 deletion PMDDotNETPlayer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ static int Main(string[] args)
{
for (int i = fnIndex; i < args.Length; i++)
{
if (Path.GetExtension(args[i]).ToUpper().IndexOf(".M") < 0) continue;
if ((Path.GetExtension(args[i]).ToUpper().IndexOf(".M") < 0)
&& (Path.GetExtension(args[i]).ToUpper().IndexOf(".XML") < 0)
) continue;
mIndex = i;
break;
}
Expand Down
Binary file modified lib/musicDriverInterface.dll
Binary file not shown.

0 comments on commit 18b2884

Please sign in to comment.