Beispiel #1
0
        public void Init(
            byte[] srcBuf,
            Action <ChipDatum> opnaWrite, Action <long, int> opnaWaitSend,
            PMDDotNETOption addtionalPMDDotNETOption, string[] addtionalPMDOption,
            Func <string, Stream> appendFileReaderCallback,
            Func <ChipDatum, int> ppz8Write,
            Func <ChipDatum, int> ppsdrvWrite,
            Func <ChipDatum, int> p86Write)
        {
            if (srcBuf == null || srcBuf.Length < 1)
            {
                return;
            }
            List <MmlDatum> bl = new List <MmlDatum>();

            foreach (byte b in srcBuf)
            {
                bl.Add(new MmlDatum(b));
            }
            Init(bl.ToArray(), opnaWrite, opnaWaitSend, addtionalPMDDotNETOption, addtionalPMDOption
                 , appendFileReaderCallback
                 , ppz8Write
                 , ppsdrvWrite
                 , p86Write
                 );
        }
Beispiel #2
0
        public void Init(string fileName, Action <ChipDatum> opnaWrite, Action <long, int> opnaWaitSend, MmlDatum[] srcBuf, object addtionalOption)
        {
            object[] option = (object[])addtionalOption;

            object[]        pdnos = (object[])option[0];
            PMDDotNETOption pdno  = new PMDDotNETOption()
            {
                isLoadADPCM   = (bool)pdnos[0],
                loadADPCMOnly = (bool)pdnos[1],
                isAUTO        = (bool)pdnos[2],
                isVA          = (bool)pdnos[3],
                isNRM         = (bool)pdnos[4],
                usePPS        = (bool)pdnos[5],
                usePPZ        = (bool)pdnos[6],
                isSPB         = (bool)pdnos[7],
                envPmd        = (string[])pdnos[8],
                envPmdOpt     = (string[])pdnos[9],
                srcFile       = (string)pdnos[10],
                PPCHeader     = (string)pdnos[11],
                jumpIndex     = -1
            };

            Func <string, Stream> appendFileReaderCallback =
                (pdnos.Length < 13 || pdnos[12] == null)
                ? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName))
                : (Func <string, Stream>)pdnos[12];

            if (pdnos.Length == 14)
            {
                pdno.jumpIndex = (int)pdnos[13];
            }


            string[] po = (string[])option[1];
            Func <ChipDatum, int> ppz8Write   = (Func <ChipDatum, int>)option[2];
            Func <ChipDatum, int> ppsdrvWrite = (Func <ChipDatum, int>)option[3];
            Func <ChipDatum, int> p86Write    = (Func <ChipDatum, int>)option[4];

            Init(
                srcBuf,
                opnaWrite, opnaWaitSend,
                pdno, po
                , appendFileReaderCallback
                , ppz8Write
                , ppsdrvWrite
                , p86Write);

            pdnos[2] = pdno.isAUTO;
            pdnos[3] = pdno.isVA;
            pdnos[4] = pdno.isNRM;
            pdnos[5] = pdno.usePPS;
            pdnos[6] = pdno.usePPZ;
            pdnos[7] = pdno.isSPB;
        }
Beispiel #3
0
        public void Init(
            MmlDatum[] srcBuf,
            Action <ChipDatum> opnaWrite, Action <long, int> opnaWaitSend,
            PMDDotNETOption addtionalPMDDotNETOption, string[] addtionalPMDOption,
            Func <string, Stream> appendFileReaderCallback
            , Func <ChipDatum, int> ppz8Write, Func <ChipDatum, int> ppsdrvWrite, Func <ChipDatum, int> p86Write)
        {
            if (srcBuf == null || srcBuf.Length < 1)
            {
                return;
            }

            Driver.srcBuf = srcBuf;

            WriteOPNA    = opnaWrite;
            WaitSendOPNA = opnaWaitSend;
            WritePPZ8    = ppz8Write;
            WritePPSDRV  = ppsdrvWrite;
            WriteP86     = p86Write;

            work = new PW();
            GetTags();
            addtionalPMDDotNETOption.PPCHeader = CheckPPC(appendFileReaderCallback);

            work.SetOption(addtionalPMDDotNETOption, addtionalPMDOption);
            work.timer = new OPNATimer(44100, 7987200);

            //PPZ8em ppz8em = addtionalPMDDotNETOption.ppz8em;
            //PPSDRV ppsdrv = addtionalPMDDotNETOption.ppsdrv;

            pmd = new PMD(
                srcBuf,
                WriteRegister,
                work,
                appendFileReaderCallback,
                WritePPZ8,
                WritePPSDRV,
                WriteP86
                );

            if (!string.IsNullOrEmpty(pmd.pw.ppcFile))
            {
                pmd.pcmload.pcm_all_load(pmd.pw.ppcFile);
            }
            if (!string.IsNullOrEmpty(pmd.pw.ppz1File) || !string.IsNullOrEmpty(pmd.pw.ppz2File))
            {
                pmd.pcmload.ppz_load(pmd.pw.ppz1File, pmd.pw.ppz2File);
            }
            if (!string.IsNullOrEmpty(pmd.pw.ppsFile))
            {
                pmd.pcmload.pps_load(pmd.pw.ppsFile);
            }
        }
Beispiel #4
0
 public void Init(
     string fileName,
     Action <ChipDatum> opnaWrite, Action <long, int> opnaWaitSend,
     PMDDotNETOption addtionalPMDDotNETOption, string[] addtionalPMDOption,
     Func <string, Stream> appendFileReaderCallback,
     Func <ChipDatum, int> ppz8Write,
     Func <ChipDatum, int> ppsdrvWrite,
     Func <ChipDatum, int> p86Write)
 {
     if (Path.GetExtension(fileName).ToLower() != ".xml")
     {
         byte[] srcBuf = File.ReadAllBytes(fileName);
         if (srcBuf == null || srcBuf.Length < 1)
         {
             return;
         }
         Init(srcBuf, opnaWrite, opnaWaitSend, addtionalPMDDotNETOption, addtionalPMDOption
              , appendFileReaderCallback ?? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName))
              , ppz8Write
              , ppsdrvWrite
              , p86Write);
     }
     else
     {
         XmlSerializer serializer = new XmlSerializer(typeof(MmlDatum[]), typeof(MmlDatum[]).GetNestedTypes());
         using (StreamReader sr = new StreamReader(fileName, new UTF8Encoding(false)))
         {
             MmlDatum[] s = (MmlDatum[])serializer.Deserialize(sr);
             Init(s, opnaWrite, opnaWaitSend, addtionalPMDDotNETOption, addtionalPMDOption
                  , appendFileReaderCallback ?? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName))
                  , ppz8Write
                  , ppsdrvWrite
                  , p86Write
                  );
         }
     }
 }