示例#1
0
 static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     byte reg = (byte)GIFReg.GetBit(HighData, 0, 8);
     if (reg == (byte)GIFRegDescriptor.AD)
         return GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat);
     return GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false);
 }
示例#2
0
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat);

            xyzf.IsXYZF = true;
            if (PackedFormat && addr == (int)GIFRegDescriptor.XYZF2 && GetBit(HighData, 47, 1) == 1)
            {
                xyzf.Descriptor = GIFRegDescriptor.XYZF3;
            }
            else
            {
                xyzf.Descriptor = (GIFRegDescriptor)addr;
            }

            if (PackedFormat)
            {
                xyzf.X = GetBit(LowData, 0, 16) / 16d;
                xyzf.Y = GetBit(LowData, 32, 16) / 16d;
                xyzf.Z = (UInt32)(GetBit(HighData, 4, 24));
                xyzf.F = (UInt16)(GetBit(HighData, 36, 8));
            }
            else
            {
                xyzf.X = GetBit(LowData, 0, 16) / 16d;
                xyzf.Y = GetBit(LowData, 16, 16) / 16d;
                xyzf.Z = (UInt32)(GetBit(LowData, 32, 24));
                xyzf.F = (UInt16)(GetBit(LowData, 56, 8));
            }
            return(xyzf);
        }
示例#3
0
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegNOP nop = new GIFRegNOP(addr, LowData, HighData, PackedFormat);
            nop.Descriptor = GIFRegDescriptor.NOP;

            return nop;
        }
示例#4
0
        internal object GetGifPacketInfo(GSDump dump, int i)
        {
            if (dump.Data[i].id == GSType.Transfer)
            {
                try
                {
                    GIFTag val = GIFTag.ExtractGifTag(dump.Data[i].data, ((GSTransfer)dump.Data[i]).Path);
                    return(val);
                }
                catch (Exception)
                {
                    return(new GIFTag());
                }
            }
            else
            {
                switch (dump.Data[i].id)
                {
                case GSType.VSync:
                    return(dump.Data[i].data.Length + "|Field = " + dump.Data[i].data[0].ToString());

                case GSType.ReadFIFO2:
                    return(dump.Data[i].data.Length + "|ReadFIFO2 : Size = " + BitConverter.ToInt32(dump.Data[i].data, 0).ToString() + " byte");

                case GSType.Registers:
                    return(dump.Data[i].data.Length + "|Registers");

                default:
                    return("");
                }
            }
        }
示例#5
0
文件: GIFRegXYZF.cs 项目: tsiru/pcsx2
        public static GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat);

            xyzf.IsXYZF = true;
            if (PackedFormat && addr == (int)GIFRegDescriptor.XYZF2 && GetBit(HighData, 47, 1) == 1)
                xyzf.Descriptor = GIFRegDescriptor.XYZF3;
            else
                xyzf.Descriptor = (GIFRegDescriptor)addr;

            if (PackedFormat)
            {
                xyzf.X = GetBit(LowData, 0, 16) / 16d;
                xyzf.Y = GetBit(LowData, 32, 16) / 16d;
                xyzf.Z = (UInt32)(GetBit(HighData, 4, 24));
                xyzf.F = (UInt16)(GetBit(HighData, 36, 8));
            }
            else
            {
                xyzf.X = GetBit(LowData, 0, 16) / 16d;
                xyzf.Y = GetBit(LowData, 16, 16) / 16d;
                xyzf.Z = (UInt32)(GetBit(LowData, 32, 24));
                xyzf.F = (UInt16)(GetBit(LowData, 56, 8));
            }
            return xyzf;
        }
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegUnimpl u = new GIFRegUnimpl(addr, LowData, HighData, PackedFormat);

            u.Descriptor = (GIFRegDescriptor)addr;
            return(u);
        }
示例#7
0
文件: GIFRegNOP.cs 项目: zod331/pcsx2
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegNOP nop = new GIFRegNOP(addr, LowData, HighData, PackedFormat);

            nop.Descriptor = GIFRegDescriptor.NOP;

            return(nop);
        }
示例#8
0
 static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     GIFRegFOG u = new GIFRegFOG(addr, LowData, HighData, PackedFormat);
     u.Descriptor = (GIFRegDescriptor)addr;
     if (PackedFormat)
         u.F = (UInt16)(GetBit(HighData, 36, 8));
     else
         u.F = GetBit(LowData, 56, 8);
     return u;
 }
示例#9
0
文件: GIFRegAD.cs 项目: zod331/pcsx2
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            byte reg = (byte)GIFReg.GetBit(HighData, 0, 8);

            if (reg == (byte)GIFRegDescriptor.AD)
            {
                return(GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat));
            }
            return(GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false));
        }
示例#10
0
文件: GIFRegPrim.cs 项目: tsiru/pcsx2
 public static GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     GIFRegPRIM pr = new GIFRegPRIM(addr, LowData, HighData, PackedFormat);
     pr.Descriptor = (GIFRegDescriptor)addr;
     pr.PrimitiveType = (GS_PRIM)GetBit(LowData, 0, 3);
     pr.IIP = (GSIIP)GetBit(LowData, 3, 1);
     pr.TME = Convert.ToBoolean(GetBit(LowData, 4, 1));
     pr.FGE = Convert.ToBoolean(GetBit(LowData, 5, 1));
     pr.ABE = Convert.ToBoolean(GetBit(LowData, 6, 1));
     pr.AA1 = Convert.ToBoolean(GetBit(LowData, 7, 1));
     pr.FST = (GSFST)(GetBit(LowData, 8, 1));
     pr.CTXT = (GSCTXT)(GetBit(LowData, 9, 1));
     pr.FIX = (GSFIX)(GetBit(LowData, 10, 1));
     return pr;
 }
示例#11
0
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegFOG u = new GIFRegFOG(addr, LowData, HighData, PackedFormat);

            u.Descriptor = (GIFRegDescriptor)addr;
            if (PackedFormat)
            {
                u.F = (UInt16)(GetBit(HighData, 36, 8));
            }
            else
            {
                u.F = GetBit(LowData, 56, 8);
            }
            return(u);
        }
示例#12
0
文件: GIFRegUV.cs 项目: tsiru/pcsx2
 public static GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     GIFRegUV uv = new GIFRegUV(addr, LowData, HighData, PackedFormat);
     uv.Descriptor = (GIFRegDescriptor)addr;
     if (PackedFormat)
     {
         uv.U = GetBit(LowData, 0, 14) / 16d;
         uv.V = GetBit(LowData, 32, 14) / 16d;
     }
     else
     {
         uv.U = GetBit(LowData, 0, 14) / 16d;
         uv.V = GetBit(LowData, 16, 14) / 16d;
     }
     return uv;
 }
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegPRIM pr = new GIFRegPRIM(addr, LowData, HighData, PackedFormat);

            pr.Descriptor    = (GIFRegDescriptor)addr;
            pr.PrimitiveType = (GS_PRIM)GetBit(LowData, 0, 3);
            pr.IIP           = (GSIIP)GetBit(LowData, 3, 1);
            pr.TME           = Convert.ToBoolean(GetBit(LowData, 4, 1));
            pr.FGE           = Convert.ToBoolean(GetBit(LowData, 5, 1));
            pr.ABE           = Convert.ToBoolean(GetBit(LowData, 6, 1));
            pr.AA1           = Convert.ToBoolean(GetBit(LowData, 7, 1));
            pr.FST           = (GSFST)(GetBit(LowData, 8, 1));
            pr.CTXT          = (GSCTXT)(GetBit(LowData, 9, 1));
            pr.FIX           = (GSFIX)(GetBit(LowData, 10, 1));
            return(pr);
        }
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegUV uv = new GIFRegUV(addr, LowData, HighData, PackedFormat);

            uv.Descriptor = (GIFRegDescriptor)addr;
            if (PackedFormat)
            {
                uv.U = GetBit(LowData, 0, 14) / 16d;
                uv.V = GetBit(LowData, 32, 14) / 16d;
            }
            else
            {
                uv.U = GetBit(LowData, 0, 14) / 16d;
                uv.V = GetBit(LowData, 16, 14) / 16d;
            }
            return(uv);
        }
示例#15
0
文件: GIFRegST.cs 项目: tsiru/pcsx2
        public static GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegST st = new GIFRegST(addr, LowData, HighData, PackedFormat);
            st.Descriptor = (GIFRegDescriptor)addr;

            st.S = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 0);
            st.T = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
            if (PackedFormat)
            {
                st.Q = BitConverter.ToSingle(BitConverter.GetBytes(HighData), 0);
                tag.Q = st.Q;
                st.isSTQ = true;
            }
            else
                st.isSTQ = false;

            return st;
        }
示例#16
0
 static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     GIFRegTEX0 tex0 = new GIFRegTEX0(addr, LowData, HighData, PackedFormat);
     tex0.Descriptor = (GIFRegDescriptor)addr;
     tex0.TBP0 = (ushort)GetBit(LowData, 0, 14);
     tex0.TBW = (byte)GetBit(LowData, 14, 6);
     tex0.PSM = (TEXPSM)GetBit(LowData, 20, 6);
     tex0.TW = (byte)GetBit(LowData, 26, 4);
     tex0.TH = (byte)GetBit(LowData, 30, 4);
     tex0.TCC = (TEXTCC)GetBit(LowData, 34, 1);
     tex0.TFX = (TEXTFX)GetBit(LowData, 35, 2);
     tex0.CBP = (ushort)GetBit(LowData, 37, 14);
     tex0.CPSM = (TEXCPSM)GetBit(LowData, 51, 4);
     tex0.CSM = (TEXCSM)GetBit(LowData, 55, 1);
     tex0.CSA = (byte)GetBit(LowData, 56, 5);
     tex0.CLD = (byte)GetBit(LowData, 61, 3);
     return tex0;
 }
示例#17
0
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegTEX0 tex0 = new GIFRegTEX0(addr, LowData, HighData, PackedFormat);

            tex0.Descriptor = (GIFRegDescriptor)addr;
            tex0.TBP0       = (ushort)GetBit(LowData, 0, 14);
            tex0.TBW        = (byte)GetBit(LowData, 14, 6);
            tex0.PSM        = (TEXPSM)GetBit(LowData, 20, 6);
            tex0.TW         = (byte)GetBit(LowData, 26, 4);
            tex0.TH         = (byte)GetBit(LowData, 30, 4);
            tex0.TCC        = (TEXTCC)GetBit(LowData, 34, 1);
            tex0.TFX        = (TEXTFX)GetBit(LowData, 35, 2);
            tex0.CBP        = (ushort)GetBit(LowData, 37, 14);
            tex0.CPSM       = (TEXCPSM)GetBit(LowData, 51, 4);
            tex0.CSM        = (TEXCSM)GetBit(LowData, 55, 1);
            tex0.CSA        = (byte)GetBit(LowData, 56, 5);
            tex0.CLD        = (byte)GetBit(LowData, 61, 3);
            return(tex0);
        }
示例#18
0
文件: GIFRegST.cs 项目: zod331/pcsx2
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegST st = new GIFRegST(addr, LowData, HighData, PackedFormat);

            st.Descriptor = (GIFRegDescriptor)addr;

            st.S = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 0);
            st.T = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
            if (PackedFormat)
            {
                st.Q     = BitConverter.ToSingle(BitConverter.GetBytes(HighData), 0);
                tag.Q    = st.Q;
                st.isSTQ = true;
            }
            else
            {
                st.isSTQ = false;
            }

            return(st);
        }
示例#19
0
 public static GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     GIFRegRGBAQ r = new GIFRegRGBAQ(addr, LowData, HighData, PackedFormat);
     r.Descriptor = (GIFRegDescriptor)addr;
     if (PackedFormat)
     {
         r.R = (byte)GetBit(LowData, 0, 8);
         r.G = (byte)GetBit(LowData, 32, 8);
         r.B = (byte)GetBit(HighData, 0, 8);
         r.A = (byte)GetBit(HighData, 32, 8);
         r.Q = tag.Q;
     }
     else
     {
         r.R = (byte)GetBit(LowData, 0, 8);
         r.G = (byte)GetBit(LowData, 8, 8);
         r.B = (byte)GetBit(LowData, 16, 8);
         r.A = (byte)GetBit(LowData, 24, 8);
         r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
     }
     return r;
 }
示例#20
0
        static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
        {
            GIFRegRGBAQ r = new GIFRegRGBAQ(addr, LowData, HighData, PackedFormat);

            r.Descriptor = (GIFRegDescriptor)addr;
            if (PackedFormat)
            {
                r.R = (byte)GetBit(LowData, 0, 8);
                r.G = (byte)GetBit(LowData, 32, 8);
                r.B = (byte)GetBit(HighData, 0, 8);
                r.A = (byte)GetBit(HighData, 32, 8);
                r.Q = tag.Q;
            }
            else
            {
                r.R = (byte)GetBit(LowData, 0, 8);
                r.G = (byte)GetBit(LowData, 8, 8);
                r.B = (byte)GetBit(LowData, 16, 8);
                r.A = (byte)GetBit(LowData, 24, 8);
                r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
            }
            return(r);
        }
示例#21
0
        static void Server_OnClientMessageReceived(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess)
        {
            switch (Mess.MessageType)
            {
            case MessageType.Connect:
                break;

            case MessageType.MaxUsers:
                break;

            case MessageType.SizeDump:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    frmMain.txtDumpSize.Text = (((int)Mess.Parameters[0]) / 1024f / 1024f).ToString("F2") + " MB";
                }), new object[] { null });
                break;

            case MessageType.Statistics:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    frmMain.txtGIFPackets.Text = ((int)Mess.Parameters[0]).ToString();
                    frmMain.txtPath1.Text      = ((int)Mess.Parameters[1]).ToString();
                    frmMain.txtPath2.Text      = ((int)Mess.Parameters[2]).ToString();
                    frmMain.txtPath3.Text      = ((int)Mess.Parameters[3]).ToString();
                    frmMain.txtReadFifo.Text   = ((int)Mess.Parameters[5]).ToString();
                    frmMain.txtVSync.Text      = ((int)Mess.Parameters[4]).ToString();
                    frmMain.txtRegisters.Text  = ((int)Mess.Parameters[6]).ToString();
                }), new object[] { null });
                break;

            case MessageType.StateOld:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    MessageBox.Show("Savestate too old to be read. :(", "Warning");
                    frmMain.Focus();
                }), new object[] { null });
                break;

            case MessageType.GetDebugMode:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    frmMain.chkDebugMode.Checked = (Boolean)Mess.Parameters[0];

                    frmMain.lblGif.Enabled               = frmMain.chkDebugMode.Checked;
                    frmMain.btnRunToSelection.Enabled    = frmMain.chkDebugMode.Checked;
                    frmMain.treTreeView.Enabled          = frmMain.chkDebugMode.Checked;
                    frmMain.btnStep.Enabled              = frmMain.chkDebugMode.Checked;
                    frmMain.cmdGoToStart.Enabled         = frmMain.chkDebugMode.Checked;
                    frmMain.cmdGoToNextVSync.Enabled     = frmMain.chkDebugMode.Checked;
                    frmMain.treeGifPacketContent.Enabled = frmMain.chkDebugMode.Checked;
                    if (frmMain.chkDebugMode.Checked == false)
                    {
                        frmMain.treTreeView.Nodes.Clear();
                    }
                }), new object[] { null });
                break;

            case MessageType.DebugState:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    frmMain.treTreeView.Nodes.Clear();
                    List <TreeNode> parents = new List <TreeNode>();
                    List <TreeNode> nodes   = new List <TreeNode>();
                    foreach (var itm in Mess.Parameters)
                    {
                        String[] parts = itm.ToString().Split(new char[] { '|' });
                        switch (parts[1])
                        {
                        case "Transfer":
                            TreeNode tn2 = new TreeNode();
                            tn2.Name     = parts[0];
                            tn2.Text     = parts[0] + " - " + parts[1] + " - " + parts[2] + " - " + parts[3] + " byte";
                            nodes.Add(tn2);
                            break;

                        case "ReadFIFO2":
                            TreeNode tn3 = new TreeNode();
                            tn3.Name     = parts[0];
                            tn3.Text     = parts[0] + " - " + parts[1] + " - " + parts[2] + " byte";
                            nodes.Add(tn3);
                            break;

                        case "VSync":
                            TreeNode tn = new TreeNode();
                            tn.Name     = parts[0];
                            tn.Text     = parts[0] + " - " + parts[1] + " - " + parts[2] + " byte";
                            tn.Nodes.AddRange(nodes.ToArray());
                            parents.Add(tn);

                            nodes.Clear();
                            break;

                        case "Registers":
                            TreeNode tn4 = new TreeNode();
                            tn4.Name     = parts[0];
                            tn4.Text     = parts[0] + " - " + parts[1] + " - " + parts[2] + " byte";
                            nodes.Add(tn4);
                            break;
                        }
                    }
                    frmMain.treTreeView.Nodes.AddRange(parents.ToArray());
                }), new object[] { null });
                break;

            case MessageType.Step:
            case MessageType.RunToCursor:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    int idtoselect  = (int)Mess.Parameters[0];
                    TreeNode[] noes = frmMain.treTreeView.Nodes.Find(idtoselect.ToString(), true);
                    if (noes.Length > 0)
                    {
                        if (CurrentNode != null)
                        {
                            CurrentNode.BackColor = Color.White;
                        }
                        noes[0].BackColor = Color.LightBlue;
                        CurrentNode       = noes[0];
                        frmMain.treTreeView.SelectedNode = noes[0];
                    }
                }), new object[] { null });
                break;

            case MessageType.PacketInfo:
                frmMain.Invoke(new Action <object>(delegate(object e)
                {
                    if (Mess.Parameters[0].GetType() == typeof(GIFTag))
                    {
                        GIFTag tag = (GIFTag)Mess.Parameters[0];

                        frmMain.txtGifPacketSize.Text = tag.size + " bytes";
                        frmMain.treeGifPacketContent.Nodes.Clear();

                        frmMain.treeGifPacketContent.Nodes.Add("Transfer Path " + tag.path);

                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("nloop = " + tag.nloop);
                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("eop = " + tag.eop);
                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("flg = " + tag.flg.ToString());
                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("pre = " + tag.pre);

                        TreeNode nodePrim = new TreeNode("Prim");
                        string[] prim     = tag.prim.ToString().Split(new char[] { '@' });
                        for (int j = 0; j < prim.Length; j++)
                        {
                            nodePrim.Nodes.Add(prim[j]);
                        }

                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add(nodePrim);

                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("nreg = " + (tag.nreg == 0 ? (16).ToString() : tag.nreg.ToString()));

                        TreeNode nodeReg = new TreeNode("reg");
                        for (int j = 0; j < tag.regs.Count; j++)
                        {
                            string[] fvals   = tag.regs[j].ToString().Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
                            TreeNode nodeObj = new TreeNode(fvals[0]);
                            for (int z = 1; z < fvals.Length; z++)
                            {
                                TreeNode item = new TreeNode(fvals[z]);
                                nodeObj.Nodes.Add(item);
                            }
                            nodeReg.Nodes.Add(nodeObj);
                        }
                        frmMain.treeGifPacketContent.Nodes[0].Nodes.Add(nodeReg);

                        frmMain.treeGifPacketContent.Nodes[0].ExpandAll();
                    }
                    else
                    {
                        String[] vals = Mess.Parameters[0].ToString().Split('|');
                        frmMain.txtGifPacketSize.Text = vals[0] + " bytes";
                        frmMain.treeGifPacketContent.Nodes.Clear();
                        frmMain.treeGifPacketContent.Nodes.Add(vals[1]);
                        frmMain.treeGifPacketContent.Nodes[0].ExpandAll();
                    }
                }), new object[] { null });
                break;

            default:
                break;
            }
        }
示例#22
0
        static internal GIFTag ExtractGifTag(byte[] data,GSTransferPath path)
        {
            GIFTag t = new GIFTag();

            t.size = data.Length;
            t.path = path;
            t.TAG  = BitConverter.ToUInt64(data,0);
            t.REGS = BitConverter.ToUInt64(data,8);

            t.Q     = 1f;
            t.nloop = (uint)GetBit(t.TAG,0,15);
            t.eop   = (uint)GetBit(t.TAG,15,1);
            t.pre   = (uint)GetBit(t.TAG,46,1);
            t.prim  = GIFPrim.ExtractGIFPrim((uint)GetBit(t.TAG,47,11));
            t.flg   = (GIFFLG)GetBit(t.TAG,58,2);
            t.nreg  = (uint)GetBit(t.TAG,60,4);
            if (t.nreg == 0)
            {
                t.nreg = 16;
            }

            byte[]   registers  = new byte[t.nreg];
            Unpack[] regsunpack = new Unpack[t.nreg];

            t.regs = new List <IGifData>();
            for (byte i = 0; i < t.nreg; i++)
            {
                byte reg = (byte)GetBit(t.REGS,i * 4,4);
                registers[i]  = reg;
                regsunpack[i] = GetUnpack(reg);
            }

            int p = 16;

            switch (t.flg)
            {
            case GIFFLG.GIF_FLG_PACKED:
                for (int j = 0; j < t.nloop; j++)
                {
                    for (int i = 0; i < t.nreg; i++)
                    {
                        UInt64 LowData  = BitConverter.ToUInt64(data,p);
                        UInt64 HighData = BitConverter.ToUInt64(data,p + 8);
                        t.regs.Add(regsunpack[i](t,registers[i],LowData,HighData,true));
                        p += 16;
                    }
                }
                break;

            case GIFFLG.GIF_FLG_REGLIST:
                for (int j = 0; j < t.nloop; j++)
                {
                    for (int i = 0; i < t.nreg; i++)
                    {
                        UInt64 Data = BitConverter.ToUInt64(data,p);
                        t.regs.Add(regsunpack[i](t,registers[i],Data,0,false));
                        p += 8;
                    }
                }
                break;

            case GIFFLG.GIF_FLG_IMAGE:
            case GIFFLG.GIF_FLG_IMAGE2:
                GifImage image = new GifImage();
                image.Data = new byte[t.nloop * 16];
                try
                {
                    Array.Copy(data,16,image.Data,0,t.nloop * 16);
                }
                catch (ArgumentException) { }
                t.regs.Add(image);
                break;

            default:
                break;
            }
            return(t);
        }
示例#23
0
        static internal GIFTag ExtractGifTag(byte[] data, GSTransferPath path)
        {
            GIFTag t = new GIFTag();
            t.size = data.Length;
            t.path = path;
            t.TAG = BitConverter.ToUInt64(data, 0);
            t.REGS = BitConverter.ToUInt64(data, 8);

            t.Q = 1f;
            t.nloop = (uint)GetBit(t.TAG, 0, 15);
            t.eop = (uint)GetBit(t.TAG, 15, 1);
            t.pre = (uint)GetBit(t.TAG, 46, 1);
            t.prim = GIFPrim.ExtractGIFPrim((uint)GetBit(t.TAG, 47, 11));
            t.flg = (GIFFLG)GetBit(t.TAG, 58, 2);
            t.nreg = (uint)GetBit(t.TAG, 60, 4);
            if (t.nreg == 0)
                t.nreg = 16;

            byte[] registers = new byte[t.nreg];
            Unpack[] regsunpack = new Unpack[t.nreg];

            t.regs = new List<IGifData>();
            for (byte i = 0; i < t.nreg; i++)
            {
                byte reg = (byte)GetBit(t.REGS, i * 4, 4);
                registers[i] = reg;
                regsunpack[i] = GetUnpack(reg);
            }

            int p = 16;
            switch (t.flg)
            {
                case GIFFLG.GIF_FLG_PACKED:
                    for (int j = 0; j < t.nloop; j++)
                        for (int i = 0; i < t.nreg; i++)
                        {
                            UInt64 LowData = BitConverter.ToUInt64(data, p);
                            UInt64 HighData = BitConverter.ToUInt64(data, p + 8);
                            t.regs.Add(regsunpack[i](t, registers[i], LowData, HighData, true));
                            p += 16;
                        }
                    break;
                case GIFFLG.GIF_FLG_REGLIST:
                    for (int j = 0; j < t.nloop; j++)
                        for (int i = 0; i < t.nreg; i++)
                        {
                            UInt64 Data = BitConverter.ToUInt64(data, p);
                            t.regs.Add(regsunpack[i](t, registers[i], Data, 0, false));
                            p += 8;
                        }
                    break;
                case GIFFLG.GIF_FLG_IMAGE:
                case GIFFLG.GIF_FLG_IMAGE2:
                    GifImage image = new GifImage();
                    image.Data = new byte[t.nloop * 16];
                    try
                    {
                        Array.Copy(data, 16, image.Data, 0, t.nloop * 16);
                    }
                    catch (ArgumentException) { }
                    t.regs.Add(image);
                    break;
                default:
                    break;
            }
            return t;
        }
示例#24
0
 public static GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
 {
     GIFRegUnimpl u = new GIFRegUnimpl(addr, LowData, HighData, PackedFormat);
     u.Descriptor = (GIFRegDescriptor)addr;
     return u;
 }