示例#1
0
        /// <summary>
        /// コンパイル開始
        /// </summary>
        /// <returns></returns>
        public int Start()
        {
            try
            {
                Disp(string.Format(msg.get("I04000"), "mucomMD2vgm"));
                Disp("");

                Disp(msg.get("I04001"));
                if (!File.Exists(srcFn))
                {
                    msgBox.setErrMsg(msg.get("E04000"));
                    return(-1);
                }

                Disp(msg.get("I04002"));
                string      path = Path.GetDirectoryName(Path.GetFullPath(srcFn));
                List <Line> src  = GetSrc(File.ReadAllLines(srcFn, System.Text.Encoding.GetEncoding("Shift_JIS")), path);
                if (src == null)
                {
                    msgBox.setErrMsg(msg.get("E04001"));
                    return(-1);
                }

                Disp(msg.get("I04003"));
                desVGM = new ClsVgm(stPath, srcFn);
                if (desVGM.Analyze(src) != 0)
                {
                    msgBox.setErrMsg(string.Format(
                                         msg.get("E04002")
                                         , desVGM.lineNumber));
                    return(-1);
                }

                Disp(msg.get("I04021"));
                desVGM.LoadVoicedat();

                Disp(msg.get("I04022"));
                desVGM.LoadSSGdat();

                Disp(msg.get("I04023"));
                desVGM.LoadAdpcmdat();

                Disp(msg.get("I04004"));
                if (desVGM.instPCMDatSeq.Count > 0)
                {
                    GetPCMData(path);
                }

                Disp(msg.get("I04005"));
                MMLAnalyze mmlAnalyze = new MMLAnalyze(desVGM);
                if (mmlAnalyze.Start() != 0)
                {
                    msgBox.setErrMsg(string.Format(
                                         msg.get("E04003")
                                         , mmlAnalyze.lineNumber));
                    return(-1);
                }

                byte[] desBuf = null;
                switch (desVGM.info.format)
                {
                case enmFormat.VGM:
                    Disp(msg.get("I04006"));
                    desBuf = desVGM.Vgm_getByteData(mmlAnalyze.mmlData);
                    Disp(msg.get("I04007"));
                    break;

                default:
                    break;
                }

                if (desBuf == null)
                {
                    msgBox.setErrMsg(string.Format(
                                         msg.get("E04004")
                                         , desVGM.lineNumber));
                    return(-1);
                }

                Disp(msg.get("I04010"));
                outFile(desBuf);


                Result();

                return(0);
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                msgBox.setErrMsg(string.Format(msg.get("E04005")
                                               , desVGM.lineNumber
                                               , ex.Message
                                               , ex.StackTrace));
                return(-1);
            }
            finally
            {
                Disp(msg.get("I04011"));
                Disp("");
            }
        }
示例#2
0
        /// <summary>
        /// コンパイル開始
        /// </summary>
        /// <returns></returns>
        public int Start()
        {
            try
            {
                Disp(string.Format(msg.get("I04000"), "mml2vgm"));
                Disp("");

                List <Line> src = null;

                //.gwiファイルの読み込み
                if (!bufferMode)
                {
                    Disp(msg.get("I04001"));
                    srcFn = srcFn.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
                    if (!File.Exists(srcFn))
                    {
                        msgBox.setErrMsg(msg.get("E04000"), new LinePos(srcFn));
                        return(-1);
                    }

                    Disp(msg.get("I04002"));
                    //string path = Path.GetDirectoryName(Path.GetFullPath(srcFn));
                    //wrkPath インクルードファイル取り込み対象パス
                    srcTxt = File.ReadAllLines(srcFn);
                }

                //インクルードファイルのマージ
                src = GetSrc(srcTxt, wrkPath);

                if (src == null)
                {
                    msgBox.setErrMsg(msg.get("E04001"), new LinePos(srcFn));
                    return(-1);
                }

                Disp(msg.get("I04003"));
                //ざっくりくわけ
                SourceParser sp = new SourceParser();
                sp.Parse(src);

                desVGM            = new ClsVgm(stPath, sp);
                desVGM.doSkip     = doSkip;
                desVGM.doSkipStop = doSkipStop;
                desVGM.caretPoint = caretPoint;
                desVGM.wrkPath    = wrkPath;
                if (desVGM.Analyze(src) != 0)
                {
                    msgBox.setErrMsg(string.Format(
                                         msg.get("E04002")
                                         , desVGM.linePos.row), desVGM.linePos);
                    return(-1);
                }

                Disp(msg.get("I04004"));
                //wrkPath PCMファイル取り込み対象パス
                if (desVGM.instPCMDatSeq.Count > 0)
                {
                    GetPCMData(wrkPath);
                }

                Disp(msg.get("I04005"));

                MMLAnalyze mmlAnalyze = new MMLAnalyze(desVGM);
                mmlAnalyze.doSkip     = doSkip;
                mmlAnalyze.caretPoint = caretPoint;

                if (mmlAnalyze.Start() != 0)
                {
                    msgBox.setErrMsg(string.Format(
                                         msg.get("E04003")
                                         , mmlAnalyze.linePos.row), mmlAnalyze.linePos);
                    return(-1);
                }

                if (desVGM.info.format != enmFormat.ZGM)
                {
                    switch (desVGM.info.format)
                    {
                    case enmFormat.VGM:
                        Disp(msg.get("I04006"));
                        desBuf = desVGM.Vgm_getByteData(mmlAnalyze.mmlData);
                        Disp(msg.get("I04007"));
                        break;

                    case enmFormat.XGM:
                        Disp(msg.get("I04008"));
                        desBuf = desVGM.Xgm_getByteData(mmlAnalyze.mmlData);
                        Disp(msg.get("I04009"));
                        break;

                    default:
                        break;
                    }

                    if (desBuf == null)
                    {
                        if (desVGM.linePos != null)
                        {
                            msgBox.setErrMsg(string.Format(
                                                 msg.get("E04004")
                                                 , desVGM.linePos.row), desVGM.linePos);
                        }
                        return(-1);
                    }

                    if (outVgmFile && writeFileMode)
                    {
                        Disp(msg.get("I04021"));
                        if (desVGM.info.format == enmFormat.VGM)
                        {
                            OutVgmFile(desBuf);
                        }
                        else
                        {
                            OutXgmFile(desBuf);
                        }
                    }
                }
                else
                {
                    Disp(msg.get("I04023"));
                    ZGMmaker zmake = new ZGMmaker();
                    desBuf = zmake.Build(desVGM);
                    Disp(msg.get("I04024"));

                    if (desBuf == null)
                    {
                        msgBox.setErrMsg(string.Format(
                                             msg.get("E04004")
                                             , desVGM.linePos.row), desVGM.linePos);
                        return(-1);
                    }

                    if (outVgmFile && writeFileMode)
                    {
                        Disp(msg.get("I04025"));
                        zmake.OutFile(desBuf, desFn);
                    }
                }

                if (outTraceInfoFile && writeFileMode)
                {
                    Disp(msg.get("I04022"));
                    OutTraceInfoFile(desBuf);
                }

                Result();

                FileInformation.loopCounter  = desVGM.loopClock;
                FileInformation.totalCounter = desVGM.lClock;
                FileInformation.format       = desVGM.info.format;

                return(0);
            }
            catch (Exception ex)
            {
                Disp(ex.Message);
                msgBox.setErrMsg(string.Format(msg.get("E04005")
                                               , (desVGM.linePos == null ? "-" : desVGM.linePos.row.ToString())
                                               , ex.Message
                                               , ex.StackTrace), desVGM.linePos);
                return(-1);
            }
            finally
            {
                Disp(msg.get("I04011"));
                Disp("");
            }
        }
示例#3
0
        /// <summary>
        /// コンパイル開始
        /// </summary>
        /// <returns></returns>
        public int Start()
        {
            try
            {
                Disp(string.Format(msg.get("I04000"), "mucomMD2vgm"));
                Disp("");

                Disp(msg.get("I04001"));
                if (!File.Exists(srcFn))
                {
                    msgBox.setErrMsg(msg.get("E04000"));
                    return(-1);
                }

                Disp(msg.get("I04002"));
                string      path = Path.GetDirectoryName(Path.GetFullPath(srcFn));
                List <Line> src  = GetSrc(File.ReadAllLines(srcFn, System.Text.Encoding.GetEncoding("Shift_JIS")), path);
                if (src == null)
                {
                    msgBox.setErrMsg(msg.get("E04001"));
                    return(-1);
                }

                Disp(msg.get("I04003"));
                desVGM = new ClsVgm(stPath, srcFn, isLoopEx, rendSecond);
                if (desVGM.Analyze(src) != 0)
                {
                    msgBox.setErrMsg(string.Format(
                                         msg.get("E04002")
                                         , desVGM.lineNumber));
                    return(-1);
                }

                if (desVGM.info.useOPN2 || desVGM.info.useOPM)
                {
                    Disp(msg.get("I04021"));
                    desVGM.LoadVoicedat();
                }

                if (desVGM.info.useDCSG)
                {
                    Disp(msg.get("I04022"));
                    desVGM.LoadSSGdat();
                }

                if (desVGM.info.useOPN2)
                {
                    Disp(msg.get("I04023"));
                    int i = desVGM.LoadAdpcmdat();
                    if (i > 0)
                    {
                        Disp(string.Format("ADPCM読み込まれ、PCM番号 1 から {0} まで使用されます。", i));
                    }

                    Disp(msg.get("I04004"));
                    if (desVGM.instPCMDatSeq.Count > 0)
                    {
                        GetPCMData(path);
                    }
                }

                byte[] desBuf = null;

                if (!isLoopEx)
                {
                    Disp(msg.get("I04005"));
                    MMLAnalyze mmlAnalyze = new MMLAnalyze(desVGM);
                    if (mmlAnalyze.Start() != 0)
                    {
                        msgBox.setErrMsg(string.Format(msg.get("E04003"), mmlAnalyze.lineNumber));
                        return(-1);
                    }

                    desVGM.CutYM2612();

                    switch (desVGM.info.format)
                    {
                    case enmFormat.VGM:
                        Disp(msg.get("I04006"));
                        desBuf = desVGM.Vgm_getByteData(mmlAnalyze.mmlData, enmLoopExStep.none);
                        Disp(msg.get("I04007"));
                        break;

                    case enmFormat.XGM:
                        Disp(msg.get("I04008"));
                        desBuf = desVGM.Xgm_getByteData(mmlAnalyze.mmlData, enmLoopExStep.none);
                        Disp(msg.get("I04009"));
                        break;
                    }

                    if (desBuf == null)
                    {
                        msgBox.setErrMsg(string.Format(
                                             msg.get("E04004")
                                             , desVGM.lineNumber));
                        return(-1);
                    }
                }
                else
                {
                    //Loopポイントその他の情報を採取するために一旦解析と1ループの演奏を行う。

                    Disp(msg.get("I04024"));
                    MMLAnalyze mmlAnalyze = new MMLAnalyze(desVGM);
                    if (mmlAnalyze.Start() != 0)
                    {
                        msgBox.setErrMsg(string.Format(msg.get("E04003"), mmlAnalyze.lineNumber));
                        return(-1);
                    }

                    desVGM.CutYM2612();

                    switch (desVGM.info.format)
                    {
                    case enmFormat.VGM:
                        Disp(msg.get("I04025"));
                        desBuf = desVGM.Vgm_getByteData(mmlAnalyze.mmlData, enmLoopExStep.Inspect);
                        Disp(msg.get("I04026"));
                        break;

                    case enmFormat.XGM:
                        Disp(msg.get("I04030"));
                        desBuf = desVGM.Xgm_getByteData(mmlAnalyze.mmlData, enmLoopExStep.Inspect);
                        Disp(msg.get("I04031"));
                        break;
                    }

                    msgBox.clear();

                    if (desBuf == null)
                    {
                        msgBox.setErrMsg(string.Format(
                                             msg.get("E04004")
                                             , desVGM.lineNumber));
                        return(-1);
                    }


                    //情報収集
                    Dictionary <KeyValuePair <enmChipType, int>, clsLoopInfo> dicLoopInfo = GetLoopInfo();
                    Dictionary <KeyValuePair <enmChipType, int>, long>        dicInspectedClockCounter = GetClockCounterInfo();

                    if (dicLoopInfo.Count != 0)
                    {
                        //収集した情報をもとに 本解析と演奏を行う。

                        desBuf = null;

                        Disp(msg.get("I04027"));
                        mmlAnalyze = new MMLAnalyze(desVGM);
                        if (mmlAnalyze.Start() != 0)
                        {
                            msgBox.setErrMsg(string.Format(msg.get("E04003"), mmlAnalyze.lineNumber));
                            return(-1);
                        }

                        desVGM.CutYM2612();

                        SetLoopInfo(desVGM, dicLoopInfo);
                        SetInspectedClockCounter(desVGM, dicInspectedClockCounter);

                        //1.ループ無しのパートがすべて演奏完了するまで演奏する
                        //(この間、ループ有りのパートはループ回数を消化しながらループさせる)
                        //2.ループ無しのパートがすべて演奏完了したうえで、ループ有りのパートがループ回数を完全に消化したら、
                        //もう一度ループ回数を充てんし、ループ回数を全て消化するまでループする
                        switch (desVGM.info.format)
                        {
                        case enmFormat.VGM:
                            Disp(msg.get("I04028"));
                            desBuf = desVGM.Vgm_getByteData(mmlAnalyze.mmlData, enmLoopExStep.Playing);
                            Disp(msg.get("I04029"));
                            break;

                        case enmFormat.XGM:
                            Disp(msg.get("I04032"));
                            desBuf = desVGM.Xgm_getByteData(mmlAnalyze.mmlData, enmLoopExStep.Playing);
                            Disp(msg.get("I04033"));
                            break;
                        }

                        if (desBuf == null)
                        {
                            msgBox.setErrMsg(string.Format(
                                                 msg.get("E04004")
                                                 , desVGM.lineNumber));
                            return(-1);
                        }
                    }
                }



                Disp(msg.get("I04010"));
                if (desVGM.info.format == enmFormat.VGM)
                {
                    outFile(desBuf);
                }
                else
                {
                    OutXgmFile(desBuf);
                }


                Result();

                return(0);
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                msgBox.setErrMsg(string.Format(msg.get("E04005")
                                               , (desVGM == null) ? -1 : desVGM.lineNumber
                                               , ex.Message
                                               , ex.StackTrace));
                return(-1);
            }
            finally
            {
                Disp(msg.get("I04011"));
                Disp("");
            }
        }