Ejemplo n.º 1
0
        public virtual void Setup(int chipIndex, ref uint dataPos, ref Dictionary <int, Driver.ZGM.zgm.RefAction <outDatum, uint> > cmdTable)
        {
            this.Index             = chipIndex;
            defineInfo             = new Core.DefineInfo();
            defineInfo.length      = vgmBuf[dataPos + 0x03].val;
            defineInfo.chipIdentNo = Common.getLE32(vgmBuf, dataPos + 0x4);
            defineInfo.commandNo   = (int)Common.getLE16(vgmBuf, dataPos + 0x8);
            defineInfo.clock       = (int)Common.getLE32(vgmBuf, dataPos + 0xa);
            defineInfo.option      = null;
            if (defineInfo.length > 14)
            {
                defineInfo.option = new byte[defineInfo.length - 14];
                for (int j = 0; j < defineInfo.length - 14; j++)
                {
                    defineInfo.option[j] = vgmBuf[dataPos + 0x0e + j].val;
                }
            }

            dataPos += defineInfo.length;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// DefineDiv
        /// </summary>
        private void makeDefineDiv()
        {
            log.Write("Define division");

            int cmdNo = 0x80;

            foreach (KeyValuePair <enmChipType, ClsChip[]> kvp in mmlInfo.chips)
            {
                foreach (ClsChip chip in kvp.Value)
                {
                    if (chip == null)
                    {
                        continue;
                    }
                    if (!chip.use)
                    {
                        continue;
                    }
                    if (!dicChipIdentifyNumber.ContainsKey(chip.Name))
                    {
                        continue;
                    }

                    log.Write(string.Format("Chip [{0}]", chip.Name));
                    DefineInfo di = new DefineInfo();
                    di.chip        = chip;
                    di.chipIdentNo = (uint)(int)dicChipIdentifyNumber[chip.Name][1];
                    di.commandNo   = cmdNo;
                    chip.ChipID    = di.commandNo;
                    chip.port      = new byte[(int)dicChipIdentifyNumber[chip.Name][2]][];
                    for (int i = 0; i < (int)dicChipIdentifyNumber[chip.Name][2]; i++)
                    {
                        chip.port[i] = new byte[] { (byte)cmdNo, (byte)(cmdNo >> 8) };
                        cmdNo++;
                    }

                    di.clock = chip.Frequency;
                    if (chip is YM2610B)
                    {
                        di.clock = (int)(di.clock | 0x8000_0000);
                    }

                    if (dicChipIdentifyNumber[chip.Name][4] != null)
                    {
                        di.option = new byte[((byte[])dicChipIdentifyNumber[chip.Name][4]).Length];
                        for (int i = 0; i < ((byte[])dicChipIdentifyNumber[chip.Name][4]).Length; i++)
                        {
                            di.option[i] = ((byte[])dicChipIdentifyNumber[chip.Name][4])[i];
                        }
                    }
                    define.Add(di);


                    for (int i = 0; i < chip.lstPartWork.Count; i++)
                    {
                        chip.InitPart(chip.lstPartWork[i]);
                    }
                }
            }

            ChipCommandSize         = cmdNo < 0x100 ? 1 : 2;
            mmlInfo.ChipCommandSize = ChipCommandSize;
            if (ChipCommandSize == 1)
            {
                //コマンドサイズが1byteの時はポートの配列を1byteに定義しなおす
                foreach (KeyValuePair <enmChipType, ClsChip[]> kvp in mmlInfo.chips)
                {
                    foreach (ClsChip chip in kvp.Value)
                    {
                        if (chip == null)
                        {
                            continue;
                        }

                        if (!chip.use)
                        {
                            continue;
                        }
                        if (chip.port == null)
                        {
                            continue;
                        }
                        for (int i = 0; i < chip.port.Length; i++)
                        {
                            chip.port[i] = new byte[] { chip.port[i][0] };
                        }
                    }
                }
            }

            foreach (DefineInfo di in define)
            {
                int pos = mmlInfo.dat.Count;
                di.offset = pos;
                foreach (byte b in DefineTemp)
                {
                    outDatum dt = new outDatum(enmMMLType.unknown, null, null, b);
                    mmlInfo.dat.Add(dt);
                }

                mmlInfo.dat[pos + 0x03].val = (byte)(di.length + (di.option != null ? di.option.Length : 0));
                Common.SetLE32(mmlInfo.dat, (uint)(pos + 0x04), (uint)(di.chipIdentNo));
                Common.SetLE16(mmlInfo.dat, (uint)(pos + 0x08), (ushort)(di.chip.port[0][0] + (di.chip.port[0].Length > 1 ? di.chip.port[0][1] : 0) * 256));
                Common.SetLE32(mmlInfo.dat, (uint)(pos + 0x0a), (uint)(di.clock));
                if (di.option != null)
                {
                    foreach (byte b in di.option)
                    {
                        outDatum dt = new outDatum(enmMMLType.unknown, null, null, b);
                        mmlInfo.dat.Add(dt);
                    }
                }
            }
        }