Exemple #1
0
        // MDRファイル読み出し
        private int readMDRHeader(List <MmlDatum2> destBuf, string file, ref _mdr m)
        {
            try
            {
                m.size = destBuf.Count;

                // PCM文字列位置
                m.pcmname = "";
                int pcmpos = destBuf[m.header + 0x2c].dat + destBuf[m.header + 0x2d].dat * 0x100;

                // PCM位置
                if (pcmpos == 0x8040)
                {
                    byte[] fn = new byte[0x40];
                    for (int i = 0; i < 0x40; i++)
                    {
                        fn[i] = (byte)destBuf[m.header + i].dat;
                    }
                    Common.myEncoding enc = new Common.myEncoding();
                    m.pcmname = enc.GetStringFromSjisArray(fn);
                }

                // PCM設定値
                m.pcm_packed    = destBuf[m.header + 0x2a].dat;
                m.pcm_startadrs = destBuf[m.header + 0x30].dat;
                m.pcm_startbank = destBuf[m.header + 0x31].dat;
                m.pcm_banks     = destBuf[m.header + 0x32].dat;
                m.pcm_lastsize  = destBuf[m.header + 0x33].dat;

                return(0);
            }
            catch
            {
                return(-1);
            }
        }
        private void asmDb(MmlDatum2 asm, ref int ptr)
        {
            if (assembleBlockLatest)
            {
                ptr += 2; return;
            }

            List <object> args = asm.args;

            if (args[ptr + 1] is byte)
            {
                byte n = (byte)args[ptr + 1];
                ptr += 2;
                Poke(currentBank, currentAddress++, n, asm);
            }
            else if (args[ptr + 1] is int)
            {
                byte n = (byte)(int)args[ptr + 1];
                ptr += 2;
                Poke(currentBank, currentAddress++, n, asm);//int であってもbyte扱いです
            }
            else if (args[ptr + 1] is char)
            {
                byte n = (byte)(char)args[ptr + 1];
                ptr += 2;
                Poke(currentBank, currentAddress++, n, asm);
            }
            else if (args[ptr + 1] is string)
            {
                //複合型
                string      sen = (string)args[ptr + 1];
                List <byte> wd  = new List <byte>();
                for (int i = 0; i < sen.Length; i++)
                {
                    if (sen[i] == ' ' || sen[i] == '\t')
                    {
                        continue;
                    }
                    if (sen[i] == ',')
                    {
                        continue;
                    }

                    int    j;
                    string x = "";

                    if (sen[i] == '"')
                    {
                        x = "";
                        j = i + 1;
                        for (; j < sen.Length; j++)
                        {
                            if (sen[j] == '"')
                            {
                                break;
                            }
                            x += sen[j];
                        }
                        i = j;

                        Common.myEncoding enc = new Common.myEncoding();
                        byte[]            ary = enc.GetSjisArrayFromString(x);
                        foreach (byte b in ary)
                        {
                            wd.Add(b);
                        }
                        continue;
                    }

                    x = "";
                    j = i;
                    for (; j < sen.Length; j++)
                    {
                        if (sen[i] == ' ' || sen[i] == '\t' || sen[i] == ',')
                        {
                            break;
                        }
                        x += sen[j];
                    }
                    i = j;
                    int n = GetInt(x);
                    wd.Add((byte)n);
                }

                ptr += 2;
                foreach (byte b in wd)
                {
                    Poke(currentBank, currentAddress++, b, asm);
                }
            }
            else
            {
                Log.WriteLine(LogLevel.ERROR, "Db error.");
                ptr++;
            }
        }