APU_Play_Mega.Form1.UploadSPCRam C# (CSharp) Method

UploadSPCRam() private method

private UploadSPCRam ( BinaryReader filestream ) : void
filestream BinaryReader
return void
        private void UploadSPCRam(BinaryReader filestream)
        {
            timer1.Enabled = false;
            var dataBytes = new byte[66048];
            var tagBytes = new byte[0x7E02];
            filestream.Read(dataBytes, 0x10000, 0x100);
            filestream.Read(dataBytes, 0, 0x10000);
            filestream.Read(dataBytes, 0x10100, 0x100);
            var tagSize = filestream.Read(tagBytes, 2, 0x7E00);
            tagBytes[0] = (byte)(tagSize >> 8);
            tagBytes[1] = (byte) (tagSize & 0xFF);

            InitProgressBar(66, 0, 0);

            filestream.Close();
            serialPort.Write("D0U");

            for (var i = 0; i < 256; i += 4)
            {
                UpdateProgressBar();
                serialPort.Write(dataBytes, i * 0x100, 0x400);
            }
            serialPort.Write(dataBytes, 0x10000, 0x200);
            UpdateProgressBar();

            serialPort.Write(tagBytes, 0, tagSize + 2);
            UpdateProgressBar();

            serialPort.Write("D1");

            HideProgressBar();

            timer1.Enabled = true;
        }