Ejemplo n.º 1
0
        /// <summary>
        /// fills the chosen rectangle with a color in 0x00RRGGBB format
        /// </summary>
        public async Task FillRect(ushort x, ushort y, ushort w, ushort h, uint color)
        {
            var opcode = new OpcodeData(0xA2, x, y, w, h);

            opcode._wColor(color);
            await _send(opcode);
        }
Ejemplo n.º 2
0
        public async Task Pad()
        {
            var opcode = new OpcodeData(0xAF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);

            opcode._w32(0xFFFFFFFF);
            await _send(opcode);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Copies a specific rectangle from the screen to somewhere else on the screen.
        /// </summary>
        public async Task CopyRect(ushort x, ushort y, ushort w, ushort h, ushort from_x, ushort from_y)
        {
            var opcode = new OpcodeData(0xA4, x, y, w, h);

            opcode._w16(from_x);
            opcode._w16(from_y);
            await _send(opcode);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Blits a bitmap. Pixel order is BGR here!
        /// </summary>
        public async Task BlitBitmap(ushort x, ushort y, ushort w, ushort h, byte[] data)
        {
            var opcode = new OpcodeData(0xA6, x, y, w, h);

            opcode._write(data);
            opcode._wPad(4);

            await _send(opcode);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Writes a 1-color bitmap, background transparent. Format is horizontal, then vertical, with rows padded out to full bytes.
        /// </summary>
        public async Task MaskedFill(ushort x, ushort y, ushort w, ushort h, uint color, byte[] bitmap)
        {
            var opcode = new OpcodeData(0xA3, x, y, w, h);

            opcode._wColor(color);
            opcode._write(bitmap);
            opcode._wPad(4);
            await _send(opcode);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Writes a 2-color bitmap. Format is horizontal, then vertical, with rows padded out to full bytes.
        /// </summary>
        public async Task ExpandBitmap(ushort x, ushort y, ushort w, ushort h, uint bg, uint fg, byte[] bitmap)
        {
            Debug.Assert(bitmap.Length == (w + 7) / 8 * h);

            var opcode = new OpcodeData(0xA5, x, y, w, h);

            opcode._wColor(bg);
            opcode._wColor(fg);
            opcode._write(bitmap);
            opcode._wPad(4);
            await _send(opcode);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sets the mouse cursor. Probably cbitmap switches between bg and fg, mbitmap is transparency?
        /// </summary>
        public async Task SetMouseCursor(ushort x, ushort y, ushort w, ushort h, uint bg, uint fg, byte[] cbitmap, byte[] mbitmap)
        {
            Debug.Assert(cbitmap.Length == (w * h) >> 4);
            Debug.Assert(mbitmap.Length == (w * h) >> 4);

            var opcode = new OpcodeData(0xA9, x, y, w, h);

            opcode._wColor(bg);
            opcode._wColor(fg);
            opcode._write(cbitmap);
            opcode._write(mbitmap);
            opcode._wPad(4);
            await _send(opcode);
        }
Ejemplo n.º 8
0
        private async Task _send(OpcodeData opcode)
        {
            int toGo   = (int)opcode.Data.Length;
            var data   = opcode.Data.ToArray();
            int offset = 0;

            await _beginPacket(false);

            while (toGo > 0)
            {
                int nextBlob = toGo < (MAX_PACKET_SIZE - 16) ? toGo : (MAX_PACKET_SIZE - 16);
                await _packetCache.WriteAsync(data, offset, nextBlob);

                toGo   -= nextBlob;
                offset += nextBlob;
                if (toGo != 0)
                {
                    await _beginPacket(true);
                }
            }
            await _endPacket();
        }