using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.T2MI.Packets.Subparts
{
    internal class SubpartIq : Subpart
    {
        public override ushort Variety => 1;

        public SubpartIq(byte[] buffer)
        {
            MemoryStream ms = new MemoryStream(buffer, false);
            Length = (int)(ms.Length / 3);
            byte a, b, c;
            RealParts = new ushort[Length];
            ImaginaryParts = new ushort[Length];

            for (int i = 0; i < Length; i++)
            {
                a = ms.ReadUInt8();
                b = ms.ReadUInt8();
                c = ms.ReadUInt8();
                RealParts[i] = (ushort)a;
                RealParts[i] <<= 4;
                RealParts[i] += (ushort)((b & 0xf0) >> 4);
                ImaginaryParts[i] = (ushort)((b & 0x0f));
                ImaginaryParts[i] <<= 8;
                ImaginaryParts[i] += c;
            }
        }

        public int Length;
        public ushort[] RealParts;
        public ushort[] ImaginaryParts;
    }
}
