Skip to content

Commit

Permalink
コンパイルの高速化。
Browse files Browse the repository at this point in the history
多重音色定義した場合の挙動修正。
#コマンドの廃止。
  • Loading branch information
kuma committed May 24, 2018
1 parent 9b7b5d4 commit 150c705
Show file tree
Hide file tree
Showing 5 changed files with 585 additions and 30 deletions.
2 changes: 1 addition & 1 deletion mml2vgm MMLコマンドメモ.txt
Expand Up @@ -568,7 +568,7 @@ mn ---------------------o HuC6280PCMモード指定(0: 停止 1:
Tn oooooooooooooooooooooo テンポ(1 - 1200)
! oooooooooooooooooooooo このパートのこれ以降をコンパイルしない(発音しない)
Kn ooo-ooooo-oooo-ooooooo 移調絶対指定 ( -12 - +12 )
#n oooooooooooooooooooooo 音長をクロック値で指定
#n(廃止) oooooooooooooooooooooo 音長をクロック値で指定(lコマンドの後に#でクロック指定してください)
pn o-oo--o--ooo--ooo--o-- パン (0: 発音しない 1: 右 2: 左 3: 中央)
pn1,n2 -----o---------------o パン (n1: 左 0 - 15 n2: 右 0 - 15 )
pn1,n2 --------------------o- パン (n1: 左 0 - 127 n2: 右 0 - 127)
Expand Down
29 changes: 22 additions & 7 deletions mml2vgm/Core/clsVgm.cs
Expand Up @@ -868,11 +868,14 @@ private int SetInstrument(string vals, string srcFn, int lineNumber)

if (instrumentCounter == instrumentBufCache.Length)
{
//すでに定義済みの場合はいったん削除する(後に定義されたものが優先)
if (instFM.ContainsKey(instrumentBufCache[0]))
{
instFM.Remove(instrumentBufCache[0]);
}
else if(instrumentBufCache.Length == Const.INSTRUMENT_SIZE)


if(instrumentBufCache.Length == Const.INSTRUMENT_SIZE)
{
//M
instFM.Add(instrumentBufCache[0], instrumentBufCache);
Expand Down Expand Up @@ -1204,9 +1207,15 @@ public byte[] GetByteData()
while (pw.waitCounter == 0 && !pw.dataEnd)
{
char cmd = pw.getChar();
lineNumber = pw.getLineNumber();

Commander(pw, cmd);
if (cmd == 0)
{
pw.dataEnd = true;
}
else
{
lineNumber = pw.getLineNumber();
Commander(pw, cmd);
}
}

}
Expand Down Expand Up @@ -1485,9 +1494,15 @@ private void Xgm_procChip(ClsChip chip)
while (pw.waitCounter == 0 && !pw.dataEnd)
{
char cmd = pw.getChar();
lineNumber = pw.getLineNumber();

Commander(pw, cmd);
if (cmd == 0)
{
pw.dataEnd = true;
}
else
{
lineNumber = pw.getLineNumber();
Commander(pw, cmd);
}
}
}
}
Expand Down
198 changes: 198 additions & 0 deletions mml2vgm/Core/partWork.cs
Expand Up @@ -403,13 +403,22 @@ public string getSrcFn()
/// <returns></returns>
public char getChar()
{
//if (dataEnd) return (char)0;

char ch;
if (pos.alies == "")
{
if (pData[pos.row].Txt.Length <= pos.col) {
return (char)0;
}
ch = pData[pos.row].Txt[pos.col];
}
else
{
if (aData[pos.alies].Txt.Length <= pos.col)
{
return (char)0;
}
ch = aData[pos.alies].Txt[pos.col];
}
//Console.Write(ch);
Expand Down Expand Up @@ -460,6 +469,24 @@ public void setPos(int tCol)
return;
}

if (LstPos == null) MakeLstPos();

int i = 0;
while (i != LstPos.Count && tCol >= LstPos[i].tCol)
{
i++;
}

pos.tCol = tCol;
pos.alies = LstPos[i - 1].alies;
pos.col = LstPos[i - 1].col + tCol - LstPos[i - 1].tCol;
pos.row = LstPos[i - 1].row;
//if (pos.alies == "" && pos.col >= pData[pos.row].Txt.Length - 1 && pos.row >= pData.Count - 1)
//{
// dataEnd = true;
//}
return;

dataEnd = false;

int row = 0;
Expand Down Expand Up @@ -600,6 +627,177 @@ public void setPos(int tCol)

}

private List<clsPos> LstPos = null;

public void MakeLstPos()
{
if (pData == null)
{
return;
}

int tCol = 0;
int row = 0;
int col = 0;
string aliesName = "";

LstPos = new List<clsPos>();
LstPos.Add(new clsPos());
resetPos();

while (true)
{
string data;
char ch;

//読みだすデータの頭出し
if (aliesName == "")
{
if (pData.Count == row)
{
return;
}
data = pData[row].Txt;
}
else
{
data = aData[aliesName].Txt;
}

//解析行の解析位置が終端に達したときの処理
while (data.Length == col)
{
if (aliesName == "")
{
row++;
if (pData.Count == row)
{
break;
}
else
{
data = pData[row].Txt;
col = 0;

clsPos p = new clsPos();
p.tCol = tCol;
p.alies = "";
p.col = 0;
p.row = row;
LstPos.Add(p);

break;
}
}
else
{
clsPos p = stackPos.Pop();
aliesName = p.alies;
col = p.col;
row = p.row;
if (aliesName == "")
{
data = pData[row].Txt;
}
else
{
data = aData[aliesName].Txt;
}

p.tCol = tCol;
LstPos.Add(p);
}
}

ch = data[col];

//解析位置でエイリアス指定されている場合
while (ch == '%')
{
string a = getAliesName(data, col);
if (a != "")
{
clsPos p = new clsPos();
p.alies = aliesName;
p.col = col + a.Length + 1;
p.row = row;
stackPos.Push(p);

data = aData[a].Txt;
col = 0;
aliesName = a;
row = 0;

p = new clsPos();
p.tCol = tCol;
p.alies = a;
p.col = 0;
p.row = 0;
LstPos.Add(p);
}
else
{
msgBox.setWrnMsg("指定されたエイリアス名は定義されていません。"
, (aliesName == "") ? pData[row].Fn : aData[aliesName].Fn
, (aliesName == "") ? pData[row].Num : aData[aliesName].Num
);
col++;
}

ch = data[col];
}

tCol++;
col++;
//解析行の解析位置が終端に達したときの処理
while (data.Length == col)
{
if (aliesName == "")
{
row++;
if (pData.Count == row)
{
break;
}
else
{
data = pData[row].Txt;
col = 0;

clsPos p = new clsPos();
p.tCol = tCol;
p.alies = "";
p.col = 0;
p.row = row;
LstPos.Add(p);

break;
}
}
else
{
clsPos p = stackPos.Pop();
aliesName = p.alies;
col = p.col;
row = p.row;
if (aliesName == "")
{
data = pData[row].Txt;
}
else
{
data = aData[aliesName].Txt;
}

p.tCol = tCol;
LstPos.Add(p);
}
}

}

}

/// <summary>
/// 解析位置から数値を取得する。
/// </summary>
Expand Down

0 comments on commit 150c705

Please sign in to comment.