예제 #1
0
        public static VHProgram Load(byte[] data, byte[] tonedata, bool isoldversion)
        {
            if (data.Length != 16)
            {
                throw new ArgumentException("Value must be 16 bytes long.", "data");
            }
            if (tonedata.Length != 32 * 16)
            {
                throw new ArgumentException("Value must be 512 bytes long.", "tonedata");
            }
            byte  tonecount = data[0];
            byte  volume    = data[1];
            byte  priority  = data[2];
            byte  mode      = data[3];
            byte  panning   = data[4];
            byte  reserved1 = data[5];
            short attribute = BitConv.FromInt16(data, 6);
            int   reserved2 = BitConv.FromInt32(data, 8);
            int   reserved3 = BitConv.FromInt32(data, 12);

            if (tonecount < 0 || tonecount > 16)
            {
                ErrorManager.SignalError("VHProgram: Tone count is wrong");
            }
            if (reserved1 != (isoldversion ? 0x00 : 0xFF))
            {
                ErrorManager.SignalIgnorableError("VHProgram: Reserved value 1 is wrong");
            }
            if (reserved2 != -1)
            {
                ErrorManager.SignalIgnorableError("VHProgram: Reserved value 2 is wrong");
            }
            if (reserved3 != -1)
            {
                ErrorManager.SignalIgnorableError("VHProgram: Reserved value 3 is wrong");
            }
            VHTone[] tones = new VHTone [tonecount];
            for (int i = 0; i < tonecount; i++)
            {
                byte[] thistonedata = new byte [32];
                Array.Copy(tonedata, i * 32, thistonedata, 0, 32);
                tones[i] = VHTone.Load(thistonedata);
            }
            return(new VHProgram(isoldversion, volume, priority, mode, panning, attribute, tones));
        }
예제 #2
0
 public static VHProgram Load(byte[] data,byte[] tonedata,bool isoldversion)
 {
     if (data.Length != 16)
         throw new ArgumentException("Value must be 16 bytes long.","data");
     if (tonedata.Length != 32 * 16)
         throw new ArgumentException("Value must be 512 bytes long.","tonedata");
     byte tonecount = data[0];
     byte volume = data[1];
     byte priority = data[2];
     byte mode = data[3];
     byte panning = data[4];
     byte reserved1 = data[5];
     short attribute = BitConv.FromInt16(data,6);
     int reserved2 = BitConv.FromInt32(data,8);
     int reserved3 = BitConv.FromInt32(data,12);
     if (tonecount < 0 || tonecount > 16)
     {
         ErrorManager.SignalError("VHProgram: Tone count is wrong");
     }
     if (reserved1 != (isoldversion ? 0x00 : 0xFF))
     {
         ErrorManager.SignalIgnorableError("VHProgram: Reserved value 1 is wrong");
     }
     if (reserved2 != -1)
     {
         ErrorManager.SignalIgnorableError("VHProgram: Reserved value 2 is wrong");
     }
     if (reserved3 != -1)
     {
         ErrorManager.SignalIgnorableError("VHProgram: Reserved value 3 is wrong");
     }
     VHTone[] tones = new VHTone [tonecount];
     for (int i = 0;i < tonecount;i++)
     {
         byte[] thistonedata = new byte [32];
         Array.Copy(tonedata,i * 32,thistonedata,0,32);
         tones[i] = VHTone.Load(thistonedata);
     }
     return new VHProgram(isoldversion,volume,priority,mode,panning,attribute,tones);
 }