Example #1
0
 // Reset values and indices when new vBIOS is open.
 private void InitForm()
 {
     bios                         = null;
     checksumValue                = -1;
     textBoxModel.BackColor       = Color.LightYellow;
     textBoxBiosName.BackColor    = Color.LightYellow;
     textBoxModel.Text            = "";
     textBoxBoard.Text            = "";
     textBoxBiosName.Text         = "";
     textBoxVersion.Text          = "";
     textBoxDate.Text             = "";
     numericUpDownTdpBase.Value   = 0;
     numericUpDownTdpMax.Value    = 0;
     numericUpDownTemp1Base.Value = 0;
     numericUpDownTemp1Max.Value  = 0;
     numericUpDownTemp1Min.Value  = 0;
     numericUpDownP1Base.Value    = 0;
     numericUpDownP1Max.Value     = 0;
     numericUpDownP2Base.Value    = 0;
     numericUpDownP2Max.Value     = 0;
     numericUpDownP3Base.Value    = 0;
     numericUpDownP3Max.Value     = 0;
     numericUpDownTemp2Base.Value = 0;
     numericUpDownTemp2Max.Value  = 0;
     numericUpDownTemp2Min.Value  = 0;
     tdpAdjustable.Checked        = false;
     tdpFixed.Checked             = false;
     tempAdjustable.Checked       = false;
     tempFixed.Checked            = false;
     headerPreserve.Checked       = true;
     headerRemove.Checked         = false;
 }
Example #2
0
        // Load vBIOS file into byte array.
        // Loop through byte by byte to locate predefined addresses and set values in form.
        private void OpenBIOS_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Title  = "Open BIOS";
            open.Filter = "BIOS Files (*.rom; *.bin)|*.rom;*.bin";

            if (open.ShowDialog() == DialogResult.OK)
            {
                // Load models config file.
                processor.ReadConfigFile("PascalTDPTweaker.Models.config", "Generic");

                InitForm();
                textBoxFileName.Text = open.SafeFileName;
                DateTime lastModified = File.GetLastWriteTime(open.FileName);
                textBoxModifiedDate.Text = lastModified.ToString(FORMAT);
                bios = new Models.Firmware.Bios(File.ReadAllBytes(open.FileName));
                open.Dispose();

                checksumValue = Controllers.BiosController.CalculateChecksum(bios.ByteArray, textBoxChecksum32, numericUpDownTargetChecksum32);
                globalCounter = 0;

                // Sequentially read bytes; compare bytes read with addresses in 'Models.config'.
                // If address matched, set index and display value in form.
                for (int i = 0; i < bios.Length(); i++)
                {
                    // Break for-loop once all indices are set.
                    if (globalCounter == NUM_ADDR)
                    {
                        break;
                    }

                    // Index to determine if black screen fix is needed.
                    bios.IndexCollection.BlackSreenIndex = SetValueIndex(processor.StartAdr.ID, bios.ByteArray, i, processor.StartAdr.Low, processor.StartAdr.High, null, 0, bios.IndexCollection.BlackSreenIndex, 1);

                    // vBIOS information section. //
                    bios.IndexCollection.DateIndex    = SetTextIndex(processor.DateAdr.ID, bios.ByteArray, i, processor.DateAdr.Low, processor.DateAdr.High, textBoxDate, 1, bios.IndexCollection.DateIndex, 0);
                    bios.IndexCollection.VersionIndex = SetTextIndex(processor.VerAdr.ID, bios.ByteArray, i, processor.VerAdr.Low, processor.VerAdr.High, textBoxVersion, 1, bios.IndexCollection.VersionIndex, 0);
                    bios.IndexCollection.BoardIndex   = SetTextIndex(processor.BoardAdr.ID, bios.ByteArray, i, processor.BoardAdr.Low, processor.BoardAdr.High, textBoxBoard, 1, bios.IndexCollection.BoardIndex, 0);
                    bios.IndexCollection.DeviceIndex  = SetTextIndex(processor.DeviceAdr.ID, bios.ByteArray, i, processor.DeviceAdr.Low, processor.DeviceAdr.High, textBoxDeviceID, 3, bios.IndexCollection.DeviceIndex, 1);
                    // End information section.

                    // To be modded. //
                    // TDP section. //
                    bios.IndexCollection.TdpSliderIndex = SetRadioIndex(processor.TdpSliderAdr.ID, bios.ByteArray, i, processor.TdpSliderAdr.Low, processor.TdpSliderAdr.High, tdpAdjustable, tdpFixed, processor.TdpSliderSignal.Config, bios.IndexCollection.TdpSliderIndex);
                    bios.IndexCollection.BaseTdpIndex   = SetValueIndex(processor.BaseTdpAdr.ID, bios.ByteArray, i, processor.BaseTdpAdr.Low, processor.BaseTdpAdr.High, numericUpDownTdpBase, 1, bios.IndexCollection.BaseTdpIndex, 0);
                    bios.IndexCollection.MaxTdpIndex    = SetValueIndex(processor.MaxTdpAdr.ID, bios.ByteArray, i, processor.MaxTdpAdr.Low, processor.MaxTdpAdr.High, numericUpDownTdpMax, 1, bios.IndexCollection.MaxTdpIndex, 0);
                    // End TDP section.

                    // Advanced power section. //
                    bios.IndexCollection.P1BaseTdpIndex = SetValueIndex(processor.Power1BaseAdr.ID, bios.ByteArray, i, processor.Power1BaseAdr.Low, processor.Power1BaseAdr.High, numericUpDownP1Base, 1, bios.IndexCollection.P1BaseTdpIndex, 0);
                    bios.IndexCollection.P1MaxTdpIndex  = SetValueIndex(processor.Power1MaxAdr.ID, bios.ByteArray, i, processor.Power1MaxAdr.Low, processor.Power1MaxAdr.High, numericUpDownP1Max, 1, bios.IndexCollection.P1MaxTdpIndex, 0);

                    bios.IndexCollection.P2BaseTdpIndex = SetValueIndex(processor.Power2BaseAdr.ID, bios.ByteArray, i, processor.Power2BaseAdr.Low, processor.Power2BaseAdr.High, numericUpDownP2Base, 1, bios.IndexCollection.P2BaseTdpIndex, 0);
                    bios.IndexCollection.P2MaxTdpIndex  = SetValueIndex(processor.Power2MaxAdr.ID, bios.ByteArray, i, processor.Power2MaxAdr.Low, processor.Power2MaxAdr.High, numericUpDownP2Max, 1, bios.IndexCollection.P2MaxTdpIndex, 0);

                    bios.IndexCollection.P3BaseTdpIndex = SetValueIndex(processor.Power3BaseAdr.ID, bios.ByteArray, i, processor.Power3BaseAdr.Low, processor.Power3BaseAdr.High, numericUpDownP3Base, 1, bios.IndexCollection.P3BaseTdpIndex, 0);
                    bios.IndexCollection.P3MaxTdpIndex  = SetValueIndex(processor.Power3MaxAdr.ID, bios.ByteArray, i, processor.Power3MaxAdr.Low, processor.Power3MaxAdr.High, numericUpDownP3Max, 1, bios.IndexCollection.P3MaxTdpIndex, 0);
                    // End advanced power section.

                    // Temperature section. //
                    bios.IndexCollection.TempSliderIndex = SetRadioIndex(processor.TempSliderAdr.ID, bios.ByteArray, i, processor.TempSliderAdr.Low, processor.TempSliderAdr.High, tempAdjustable, tempFixed, processor.TempSliderSignal.Config, bios.IndexCollection.TempSliderIndex);
                    bios.IndexCollection.T1BaseTempIndex = SetValueIndex(processor.Temp1BaseAdr.ID, bios.ByteArray, i, processor.Temp1BaseAdr.Low, processor.Temp1BaseAdr.High, numericUpDownTemp1Base, 2, bios.IndexCollection.T1BaseTempIndex, 0);
                    bios.IndexCollection.T1MaxTempIndex  = SetValueIndex(processor.Temp1MaxAdr.ID, bios.ByteArray, i, processor.Temp1MaxAdr.Low, processor.Temp1MaxAdr.High, numericUpDownTemp1Max, 2, bios.IndexCollection.T1MaxTempIndex, 0);
                    bios.IndexCollection.T1MinTempIndex  = SetValueIndex(processor.Temp1MinAdr.ID, bios.ByteArray, i, processor.Temp1MinAdr.Low, processor.Temp1MinAdr.High, numericUpDownTemp1Min, 2, bios.IndexCollection.T1MinTempIndex, 0);

                    // Additional temperature settings.
                    bios.IndexCollection.T2BaseTempIndex = SetValueIndex(processor.Temp2BaseAdr.ID, bios.ByteArray, i, processor.Temp2BaseAdr.Low, processor.Temp2BaseAdr.High, numericUpDownTemp2Base, 2, bios.IndexCollection.T2BaseTempIndex, 0);
                    bios.IndexCollection.T2MaxTempIndex  = SetValueIndex(processor.Temp2MaxAdr.ID, bios.ByteArray, i, processor.Temp2MaxAdr.Low, processor.Temp2MaxAdr.High, numericUpDownTemp2Max, 2, bios.IndexCollection.T2MaxTempIndex, 0);
                    bios.IndexCollection.T2MinTempIndex  = SetValueIndex(processor.Temp2MinAdr.ID, bios.ByteArray, i, processor.Temp2MinAdr.Low, processor.Temp2MinAdr.High, numericUpDownTemp2Min, 2, bios.IndexCollection.T2MinTempIndex, 0);
                    // End Temperature section.

                    // Checksum index.
                    bios.IndexCollection.CheckSum32Index = SetValueIndex(processor.Checksum32Adr.ID, bios.ByteArray, i, processor.Checksum32Adr.Low, processor.Checksum32Adr.High, null, 0, bios.IndexCollection.CheckSum32Index, 0);
                    bios.IndexCollection.CheckSum8Index  = SetTextIndex(processor.Checksum8Adr.ID, bios.ByteArray, i, processor.Checksum8Adr.Low, processor.Checksum8Adr.High, textBoxChecksum8, 2, bios.IndexCollection.CheckSum8Index, 2);

                    // Set unknown if date index cannot be found.
                    if (bios.IndexCollection.DateIndex == -1)
                    {
                        textBoxDate.Text = "Unknown";
                    }
                }
            }
        }