예제 #1
0
        public byte[] Start(string arg)
        {
            try
            {
                srcFn      = arg;
                srcBuf     = File.ReadAllBytes(srcFn);
                workPath   = Path.GetDirectoryName(srcFn);
                mucInfo    = GetMUCInfo(srcBuf);
                fnVoicedat = string.IsNullOrEmpty(mucInfo.voice) ? "voice.dat" : System.IO.Path.Combine(workPath, mucInfo.voice);
                LoadFMVoice(fnVoicedat);
                fnPcm = string.IsNullOrEmpty(mucInfo.pcm) ? "mucompcm.bin" : System.IO.Path.Combine(workPath, mucInfo.pcm);
                LoadPCM(fnPcm);

                mucInfo.lines     = StoreBasicSource(srcBuf);
                mucInfo.voiceData = voice;
                mucInfo.pcmData   = pcmdata;
                mucInfo.basSrc    = basSrc;
                mucInfo.fnSrc     = srcFn;
                mucInfo.fnDst     = Path.ChangeExtension(srcFn, ".mub");
                mucInfo.workPath  = workPath;
                mucInfo.srcCPtr   = 0;
                mucInfo.srcLinPtr = -1;

                //MUCOM88 初期化
                int ret = muc88.COMPIL();//vector 0xeea8

                //コンパイルエラー発生時は0以外が返る
                if (ret != 0)
                {
                    int errLine = muc88.GetErrorLine();
                    Log.WriteLine(LogLevel.ERROR, string.Format(msg.get("E0100"), errLine));
                    return(null);
                }

                ret = SaveMub();
                if (ret == 0)
                {
                    return(dat.ToArray());
                }
            }
            catch (MucException me)
            {
                Log.WriteLine(LogLevel.ERROR, me.Message);
            }
            catch (Exception e)
            {
                Log.WriteLine(LogLevel.ERROR, string.Format(
                                  msg.get("E0000")
                                  , e.Message
                                  , e.StackTrace));
            }

            return(null);
        }
예제 #2
0
        public MmlDatum[] Compile(Stream sourceMML, Func <string, Stream> appendFileReaderCallback)
        {
            try
            {
                srcBuf            = ReadAllBytes(sourceMML);
                mucInfo           = GetMUCInfo(srcBuf);
                mucInfo.isIDE     = isIDE;
                mucInfo.skipPoint = skipPoint;
                mucInfo.ErrSign   = false;
                voice             = null;
                for (int i = 0; i < 6; i++)
                {
                    pcmdata[i] = null;
                }

                using (Stream vd = appendFileReaderCallback?.Invoke(string.IsNullOrEmpty(mucInfo.voice) ? "voice.dat" : mucInfo.voice))
                {
                    voice = ReadAllBytes(vd);
                }

                string[] pcmdefaultFilename = new string[]
                {
                    "mucompcm.bin",
                    "mucompcm_2nd.bin",
                    "mucompcm_3rd_B.bin",
                    "mucompcm_4th_B.bin",
                    "mucompcm_3rd_A.bin",
                    "mucompcm_4th_A.bin"
                };

                for (int i = 0; i < 6; i++)
                {
                    if (mucInfo.pcmAt[i].Count > 0)
                    {
                        pcmdata[i] = GetPackedPCM(i, mucInfo.pcmAt[i], appendFileReaderCallback);
                    }

                    if (pcmdata[i] == null)
                    {
                        using (Stream pd = appendFileReaderCallback?.Invoke(string.IsNullOrEmpty(mucInfo.pcm[i])
                        ? pcmdefaultFilename[i]
                        : mucInfo.pcm[i]))
                        {
                            pcmdata[i] = ReadAllBytes(pd);
                        }
                    }
                }

                mucInfo.lines     = StoreBasicSource(srcBuf);
                mucInfo.voiceData = voice;
                mucInfo.pcmData   = pcmdata[0];
                mucInfo.basSrc    = basSrc;
                mucInfo.srcCPtr   = 0;
                mucInfo.srcLinPtr = -1;
                //work.compilerInfo.jumpRow = -1;
                //work.compilerInfo.jumpCol = -1;

                //MUCOM88 初期化
                int ret = muc88.COMPIL();//vector 0xeea8

                //コンパイルエラー発生時は0以外が返る
                if (ret != 0)
                {
                    int errLine = muc88.GetErrorLine();
                    work.compilerInfo.errorList.Add(
                        new Tuple <int, int, string>(
                            mucInfo.row
                            , mucInfo.col
                            , string.Format(msg.get("E0100"), mucInfo.row, mucInfo.col)
                            ));
                    Log.WriteLine(LogLevel.ERROR, string.Format(msg.get("E0100"), mucInfo.row, mucInfo.col));
                    return(null);
                }

                ret = SaveMub();
                if (ret == 0)
                {
                    return(dat.ToArray());
                }
            }
            catch (MucException me)
            {
                if (work.compilerInfo == null)
                {
                    work.compilerInfo = new CompilerInfo();
                }
                work.compilerInfo.errorList.Add(new Tuple <int, int, string>(-1, -1, me.Message));
                Log.WriteLine(LogLevel.ERROR, me.Message);
            }
            catch (Exception e)
            {
                if (work.compilerInfo == null)
                {
                    work.compilerInfo = new CompilerInfo();
                }
                work.compilerInfo.errorList.Add(new Tuple <int, int, string>(-1, -1, e.Message));
                Log.WriteLine(LogLevel.ERROR, string.Format(
                                  msg.get("E0000")
                                  , e.Message
                                  , e.StackTrace));
            }

            return(null);
        }
예제 #3
0
        public MmlDatum[] Compile(Stream sourceMML, Func <string, Stream> appendFileReaderCallback)
        {
            try
            {
                srcBuf            = ReadAllBytes(sourceMML);
                mucInfo           = GetMUCInfo(srcBuf);
                mucInfo.isIDE     = isIDE;
                mucInfo.skipPoint = skipPoint;

                using (Stream vd = appendFileReaderCallback?.Invoke(string.IsNullOrEmpty(mucInfo.voice) ? "voice.dat" : mucInfo.voice))
                {
                    voice = ReadAllBytes(vd);
                }

                using (Stream pd = appendFileReaderCallback?.Invoke(string.IsNullOrEmpty(mucInfo.pcm) ? "mucompcm.bin" : mucInfo.pcm))
                {
                    pcmdata = ReadAllBytes(pd);
                }

                mucInfo.lines     = StoreBasicSource(srcBuf);
                mucInfo.voiceData = voice;
                mucInfo.pcmData   = pcmdata;
                mucInfo.basSrc    = basSrc;
                mucInfo.srcCPtr   = 0;
                mucInfo.srcLinPtr = -1;

                //MUCOM88 初期化
                int ret = muc88.COMPIL();//vector 0xeea8

                //コンパイルエラー発生時は0以外が返る
                if (ret != 0)
                {
                    int errLine = muc88.GetErrorLine();
                    work.compilerInfo.errorList.Add(
                        new Tuple <int, int, string>(
                            mucInfo.row
                            , mucInfo.col
                            , string.Format(msg.get("E0100"), mucInfo.row, mucInfo.col)
                            ));
                    Log.WriteLine(LogLevel.ERROR, string.Format(msg.get("E0100"), mucInfo.row, mucInfo.col));
                    return(null);
                }

                ret = SaveMub();
                if (ret == 0)
                {
                    return(dat.ToArray());
                }
            }
            catch (MucException me)
            {
                work.compilerInfo.errorList.Add(new Tuple <int, int, string>(-1, -1, me.Message));
                Log.WriteLine(LogLevel.ERROR, me.Message);
            }
            catch (Exception e)
            {
                work.compilerInfo.errorList.Add(new Tuple <int, int, string>(-1, -1, e.Message));
                Log.WriteLine(LogLevel.ERROR, string.Format(
                                  msg.get("E0000")
                                  , e.Message
                                  , e.StackTrace));
            }

            return(null);
        }