Exemplo n.º 1
0
        /// <summary>
        /// Sends the packet.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public bool SendPacket(byte[] data)
        {
            uint txd = nextTXDesc++;

            if (nextTXDesc >= 16)
            {
                nextTXDesc = 0;
            }

            uint offset = txd * 4;

            // check if (oldest) descriptor is available (Bit 31/OWN = 0 available)
            if ((txDescriptor.Read32(offset + 1) & 0x80000000) == 0)
            {
                for (uint i = 0; i < data.Length; i++)
                {
                    buffers.Write8((txd * bufferSize) + i, data[i]);
                }

                ushort length = (ushort)(~data.Length);
                length++;

                // Set bits 31/OWN, 25/STP (start of packet), 24/ENP (end of packet) and two's compliment of the buffer length
                txDescriptor.Write32(offset + 1, (length & (uint)(0x0FFF)) | (uint)(0x8300F000));

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the pixel.
        /// </summary>
        /// <param name="colorIndex">Index of the color.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        public void WritePixel(byte colorIndex, ushort x, ushort y)
        {
            if (writeMethod == WriteMethod.Pixel8)
            {
                memory.Write8((uint)(y * 320 + x), colorIndex);
            }
            if (writeMethod == WriteMethod.Pixel2)
            {             // ???
                uint address = (uint)(y * 320 + x / 2);
                colorIndex = (byte)(colorIndex & 0xF);

                if ((x & 0x01) == 0)
                {
                    memory.Write8(address & 0xF, (byte)(colorIndex << 4));
                }
                else
                {
                    memory.Write8(address & 0x0F, colorIndex);
                }
            }

            // TODO: Support more video modes
        }