Exemple #1
0
 void WriteReg32(int addr, uint val)
 {
     Message msg = new Message();
     msg.type = MessageType.Message_Register32;
     msg.register32_address = (uint)addr;
     msg.register32_value = val;
     msg.Send(ns);
 }
Exemple #2
0
        void SendTestList()
        {
            Message msg = new Message();

            testData[0] = (uint)(testData.Length);
            byte[] toSend = Util.Compress(testData.Select(x => BitConverter.GetBytes(x)).SelectMany(x => x).ToArray());

            msg.type = MessageType.Message_DisplayList;
            msg.displist_size = (int)toSend.Length;
            msg.Send(ns);

            ns.Write(toSend, 0, toSend.Length);
            ns.Flush();
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Message msg = new Message();
            msg.type = MessageType.Message_Texture;

            nds.MapLCDC();

            byte[] buf = CurrProject.BuffersCompressed.Texture;
            msg.tex_addr = 0x06800000; //vram_a
            msg.tex_size = (uint)buf.Length;
            msg.Send(ns);
            ns.Write(buf, 0, buf.Length);

            if (CurrProject.Buffers.Palette.Length != 0)
            {
                buf = CurrProject.BuffersCompressed.Palette;
                msg.tex_addr = 0x06880000; //vram_e
                msg.tex_size = (uint)buf.Length;
                msg.Send(ns);
                ns.Write(buf, 0, buf.Length);
            }

            nds.MapNormal();

            AcquireScreen();
        }
Exemple #4
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (txtFilename.Text != "")
            {
                int length = (int)(new FileInfo(txtFilename.Text)).Length;
                byte[] buffer = new byte[length];

                BinaryReader fr = new BinaryReader(File.Open(txtFilename.Text, FileMode.Open));
                fr.Read(buffer, 0, length);
                fr.Close();

                byte[] toSend = Util.Compress(buffer);

                Message msg = new Message();
                msg.type = MessageType.Message_DisplayList;
                msg.displist_size = buffer.Length;
                msg.Send(ns);

                ns.Write(buffer, 0, buffer.Length);
                ns.Flush();
            }
        }
Exemple #5
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            tcpc = new TcpClient(txtHost.Text, 9393);
            tcpc.NoDelay = true;
            ns = tcpc.GetStream();

            Message msg = new Message();
            msg.Recv(ns);

            msg.type = MessageType.Message_Ack;
            msg.Send(ns);

            btnConnect.Enabled = false;
            btnConnect.Text = "connected";
            txtHost.ReadOnly = true;

            nds = new NDS(ns);
            nds.BasicTextured3DCnt();

            SendTestList();
            AcquireScreen();
        }
Exemple #6
0
        unsafe void AcquireScreen()
        {
            Message msg = new Message();
            msg.type = MessageType.Message_DisplayCapture;
            msg.Send(ns);

            msg.Recv(ns);
            int zipped_size = msg.dispcap_size;
            BinaryReader br = new BinaryReader(ns);
            byte[] zipbuf = new byte[zipped_size];
            for (int i = 0; i < zipped_size; i++)
                zipbuf[i] = br.ReadByte();

            var inf = new ICSharpCode.SharpZipLib.Zip.Compression.Inflater();
            inf.SetInput(zipbuf);
            byte[] bscreen = new byte[256 * 192 * 2];
            inf.Inflate(bscreen);

            var bmp = new Bitmap(256, 192, PixelFormat.Format32bppArgb);
            BitmapData bmpdata = bmp.LockBits(new System.Drawing.Rectangle(0, 0, 256, 192), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            byte* bp = (byte*)bmpdata.Scan0.ToPointer();
            for (int i = 0; i < 256 * 192; i++)
            {
                int r = bscreen[i * 2] & 0x1F;
                int g = ((bscreen[i * 2] & 0xE0)>>5) | ((bscreen[i*2+1] & 3)<<3);
                int b = (bscreen[i * 2 + 1] >> 2) & 0x1F;
                int a = bscreen[i * 2 + 1] >> 7;

                //todo - use same color conversion as desmume (whatever that is)
                r <<= 3;
                g <<= 3;
                b <<= 3;

                bp[i * 4 + 0] = (byte)b;
                bp[i * 4 + 1] = (byte)g;
                bp[i * 4 + 2] = (byte)r;
                bp[i * 4 + 3] = 255;
            }
            bmp.UnlockBits(bmpdata);

            if (lastScreen != null) lastScreen.Dispose();
            lastScreen = bmp;
            SetViewport(lastScreen);
        }
Exemple #7
0
 void WriteReg8(int addr, int val)
 {
     Message msg = new Message();
     msg.type = MessageType.Message_Register8;
     msg.register8_address = (uint)addr;
     msg.register8_value = (byte)val;
     msg.Send(ns);
 }