Esempio n. 1
0
        private async void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>();

            progress.ProgressChanged += ReportProgress;
            rtxtbIDE.Enabled          = false;
            statusLoadingBar2.Visible = true;
            ofd.ShowDialog();
            rtxtbIDE.Text = $"Loading file {ofd.FileName}. Please wait...";
            if (File.Exists(ofd.FileName))
            {
                Console.WriteLine("Importing file {0}", ofd.FileName);
                var watch = System.Diagnostics.Stopwatch.StartNew();
                prgm83 = Compiler.GetTI83Object(new BinaryReader(File.OpenRead(ofd.FileName)));
                watch.Stop();
                Console.WriteLine($"Read file to TI83Object took {watch.ElapsedMilliseconds} milliseconds.");
                watch.Restart();
                programCode = await Compiler.ReverseCompileAsync(new List <Byte>(prgm83.Data), progress);

                watch.Stop();
                Console.WriteLine($"Detokenize process took {watch.ElapsedMilliseconds} milliseconds.");
                fileInformationToolStripMenuItem.Enabled = true;
            }
            prgm83.AssociatedFileName = ofd.FileName;
            //Console.WriteLine("writing to ide");
            // Apply standard formatting at load
            rtxtbIDE.Text             = ApplyIDEFormatting(programCode);
            rtxtbIDE.Enabled          = true;
            statusLoadingBar2.Visible = false;
        }
Esempio n. 2
0
        public FormFileDetails(TI83Model pgrm83)
        {
            InitializeComponent();
            TI83Model prgm83 = TIIDE.prgm83;

            lblFileNameText.Text    = prgm83.AssociatedFileName;
            lblProgramNameText.Text = prgm83.Name;
            lblCommentText.Text     = prgm83.Comment;
            if (prgm83.ProtectFlag)
            {
                lblProtectedText.Text = "Yes";
            }
            else
            {
                lblProtectedText.Text = "No";
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Read *83p file information into TI83 Model
        /// </summary>
        /// <param name="binaryReader"></param>
        /// <returns>TI83Model object</returns>
        internal static TI83Model GetTI83Object(BinaryReader binaryReader)
        {
            List <byte> byteList = LoadBytes(binaryReader);

            // Create *83p file object
            TI83Model file83 = new TI83Model();

            // Load program [Type] and [Program Name]
            byte[] prgmTypeBytes = new byte[8];
            byte[] prgmNameBytes = new byte[8];
            for (int i = 0; i < 8; i++)
            {
                prgmTypeBytes [i] = byteList [i + file83.TypeOffset];
                prgmNameBytes [i] = byteList [i + file83.NameOffset];
            }
            file83.Type = Encoding.ASCII.GetString(prgmTypeBytes);
            file83.Name = Encoding.ASCII.GetString(prgmNameBytes);

            // Load program [Comment]
            byte[] prgmCommentBytes = new byte[40];
            for (int i = 0; i < 40; i++)
            {
                prgmCommentBytes [i] = byteList [i + file83.CommentOffset];
            }
            file83.Comment = Encoding.ASCII.GetString(prgmCommentBytes);

            // Load program [Data Length] (size in bytes)
            byte[] prgmDataLength = new byte[2];
            for (int i = 0; i < 2; i++)
            {
                prgmDataLength [i] = byteList [i + file83.DataLengthOffset];
            }
            file83.DataLength = (prgmDataLength [1] << 8) + prgmDataLength [0];

            // Load program [Data]
            //List<byte> prgmData = new List<byte>();
            byte[] prgmData = new byte[file83.DataLength];
            for (int i = 2; i < (file83.DataLength); i++)
            {
                prgmData [i] = byteList [i + file83.DataOffset];
            }
            file83.Data = prgmData;

            // Load program [ProtectFlag]
            if (byteList [file83.ProtectFlagOffset].Equals(6))
            {
                file83.ProtectFlag = true;
            }
            else
            {
                file83.ProtectFlag = false;
            }

            // Load program [Checksum]
            byte[] prgmChecksum   = new byte[16];
            int    checksumOffset = file83.DataLength - 16;

            for (int i = 0; i < 16; i++)
            {
                prgmChecksum [i] = byteList [i + checksumOffset];
            }
            file83.Checksum = prgmChecksum;

            return(file83);
        }