Beispiel #1
0
        static void ProcessPacked(GifPacket packet, GsProcessor processor)
        {
            DataReader reader = new DataReader(packet.Data);

            if (!packet.IgnorePrimField)
            {
                throw new NotSupportedException("Unsupported PRIM field");
            }

            for (int i = 0; i < packet.Loops; i++)
            {
                foreach (var register in packet.Registers)
                {
                    switch (register)
                    {
                    case GifRegisters.APlusD:
                        ulong data       = reader.ReadUInt64();
                        byte  regAddress = (byte)(reader.ReadUInt64() & 0xFF);
                        processor.AddOperation(regAddress, data);
                        break;

                    default:
                        throw new NotSupportedException("Unsupported register");
                    }
                }
            }
        }
Beispiel #2
0
        static void ProcessImage(GifPacket packet, GsProcessor processor)
        {
            DataReader reader = new DataReader(packet.Data);

            for (int i = 0; i < packet.Loops; i++)
            {
                processor.AddOperation(0x54, reader.ReadUInt64());
                processor.AddOperation(0x54, reader.ReadUInt64());
            }
        }
Beispiel #3
0
 public void SendOperationsToGs(GsProcessor processor)
 {
     foreach (var packet in Packets)
     {
         if (packet.Kind == GifPacketKind.Packed)
         {
             ProcessPacked(packet, processor);
         }
         else if (packet.Kind == GifPacketKind.Image)
         {
             ProcessImage(packet, processor);
         }
         else
         {
             throw new NotSupportedException("Unsupported GIF packet");
         }
     }
 }
Beispiel #4
0
        public static void TransferPsmCt32(GsProcessor proc, uint[] data)
        {
            byte[] blockArrament =
            {
                0,   1,  4,  5, 16, 17, 20, 21,
                2,   3,  6,  7, 18, 19, 22, 23,
                8,   9, 12, 13, 24, 25, 28, 29,
                10, 11, 14, 15, 26, 27, 30, 31
            };

            byte[] pixelArrament =
            {
                0, 1, 4, 5,  8,  9, 12, 13,
                2, 3, 6, 7, 10, 11, 14, 15
            };

            // Only for Host2Local
            int  startX       = proc.TrxPos.DestinationPosX;
            int  startY       = proc.TrxPos.DestinationPosY;
            int  bufferWidth  = proc.BitBlfBuf.DestinationBufferWidth;
            uint startPointer = proc.BitBlfBuf.DestinationBufferPointer;

            for (int x = startX; x < startX + proc.TrxReg.Width; x++)
            {
                for (int y = startY; y < startY + proc.TrxReg.Height; y++)
                {
                    int posX = x;
                    int posY = y;

                    // Get the position of the page and get relative positions;
                    int pageX = posX / 64;
                    int pageY = posY / 32;
                    int page  = pageX + pageY * bufferWidth / 64;
                    posX %= 64;
                    posY %= 32;

                    // Get the position of the block and get relative positions;
                    int blockX = posX / 8;
                    int blockY = posY / 8;
                    int block  = blockArrament[blockY * 8 + blockX];
                    posX %= 8;
                    posY %= 8;

                    // Get the position of the column and get relative positions;
                    int column = posY / 2;
                    posY %= 2;

                    // Get the position of the pixel
                    int pixel = pixelArrament[posY * 8 + posX];

                    // Get the two type of positions
                    int lineal = y * proc.TrxReg.Width + x;
                    int twoDim = page * (64 * 32) + block * (8 * 8) + column * (8 * 2) + pixel;

                    // Transfer
                    if (proc.TrxDir.Direction == Registers.TransmissionDirection.Host2Local)
                    {
                        proc.Memory[startPointer + lineal] = data[twoDim];
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
            }
        }