Skip to content

Commit

Permalink
Fixed Radeon Toggle Buttons Bugs
Browse files Browse the repository at this point in the history
Introducing File System!
Fixed Radeon Toggle Buttons Bugs
Introducing Affinity (MSI Mode and Interrupt Affinity)
1-Click Optimization has moved to sidebar!
Remade game selection presets in the Process tab.
Added Second/Third Level Data Cache and Disable OS Mitigations
Added Intel/AMD Processor Power Management in Gaming Tab
  • Loading branch information
nezhatweaks committed Nov 11, 2024
1 parent 7ff4970 commit 4839071
Show file tree
Hide file tree
Showing 49 changed files with 2,161 additions and 465 deletions.
2 changes: 1 addition & 1 deletion Assets/latest_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0.0
0.5.1.0
2 changes: 1 addition & 1 deletion src/AMD.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Height="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="20,0,0,0" />
Margin="0,0,0,0" />
</Border>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Expand Down
174 changes: 104 additions & 70 deletions src/AMD.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ private void LoadCurrentSettings()
// Load general settings
LoadRegistryValue("EnableUlps", EnableUlpsSwitch);
LoadRegistryValue("PP_ThermalAutoThrottlingEnable", ThermalThrottlingSwitch);

LoadRegistryValue("DisableBlockWrite", DisableBlockWriteSwitch);
LoadRegistryValue("StutterMode", StutterModeSwitch);


LoadRegistryValue("DisableFBCForFullScreenApp", DisableFBCForFullscreenSwitch);
LoadRegistryValue("DisableFBCSupport", DisableFBCSupportSwitch);
LoadRegistryValue("EnableAspmL0s", EnableAspmL0sSwitch);
Expand All @@ -51,6 +48,7 @@ private void LoadCurrentSettings()
LoadRegistryValue("GLPBMode_DEF", GLPBModeDefSwitch, UMDRegistryKeyPath);
}


private void LoadRegistryValue(string valueName, ToggleButton toggleButton, string? registryPath = null)
{
string path = registryPath ?? AMDRegistryKeyPath;
Expand All @@ -59,36 +57,42 @@ private void LoadRegistryValue(string valueName, ToggleButton toggleButton, stri
try
{
key = OpenRegistryKey(path);

if (key != null)
{
object? value = key.GetValue(valueName);
if (value == null)
if (value != null)
{
// Create the registry value if it doesn't exist
SetRegistryValue(key, valueName, false); // Default to false if not set
toggleButton.IsChecked = false;
toggleButton.IsChecked = GetToggleState(value);
}
else
{
toggleButton.IsChecked = GetToggleState(value);
toggleButton.IsChecked = false;
}
}
else
{
ShowError($"Registry key not found: {path}");
}
}
catch (UnauthorizedAccessException)
{
ShowError("You do not have permission to access the registry key. Please run the application as an administrator.");
ShowError("Access denied. Please run the application as an administrator.");
}
catch (Exception ex)
{
ShowError($"Error loading {valueName} value: {ex.Message}");
ShowError($"Failed to load {valueName}: {ex.Message}");
}
finally
{
key?.Close();
}
}






private RegistryKey? OpenRegistryKey(string path)
{
RegistryKey? key = Registry.LocalMachine.OpenSubKey(path);
Expand All @@ -114,15 +118,26 @@ private void LoadRegistryValue(string valueName, ToggleButton toggleButton, stri

private bool? GetToggleState(object? value)
{
return value switch
// Check for integer type (0 = disabled, 1 = enabled)
if (value is int intValue)
{
return intValue != 1;
}
// Check for byte[] (0x30 = enabled, 0x31 = disabled)
if (value is byte[] binaryValue)
{
int currentValue => currentValue != 1, // 1 means disabled
byte[] binaryValue => binaryValue.Length > 0 && binaryValue[0] == 0x30, // Assuming 0x30 means enabled
string stringValue => stringValue == "0", // Assuming "0" means enabled
_ => null // Return null for unexpected value types without showing an error
};
return binaryValue.Length > 0 && binaryValue[0] == 0x30;
}
// Check for string type ("0" = enabled, "1" = disabled)
if (value is string stringValue)
{
return stringValue == "0";
}
return null;
}



private RegistryKey? OpenRegistryKey(string path, bool writable = false)
{
// Attempt to open the specified registry key
Expand All @@ -138,25 +153,19 @@ private void LoadRegistryValue(string valueName, ToggleButton toggleButton, stri
return key;
}


private void ToggleRegistryValue(string valueName, bool enable, string? registryPath = null)
{
string path = registryPath ?? AMDRegistryKeyPath;
RegistryKey? key = null;

try
{
// Open the registry key, creating it if it doesn't exist
// Open the registry key with write access
key = OpenRegistryKey(path, writable: true);

// Ensure UMD key is created if this is a UMD setting
if (path == UMDRegistryKeyPath)
{
OpenRegistryKey(UMDRegistryKeyPath, writable: true);
}

if (key != null)
{
// Set the value, creating it if necessary
SetRegistryValue(key, valueName, enable);
mainWindow?.MarkSettingsApplied();
App.changelogUserControl?.AddLog("Applied", $"{valueName} has been set to {(enable ? "Enabled" : "Disabled")}");
Expand All @@ -177,54 +186,77 @@ private void ToggleRegistryValue(string valueName, bool enable, string? registry
}




private void SetRegistryValue(RegistryKey key, string valueName, bool enable)
{
switch (valueName)
try
{
case "EnableUlps":
case "PP_ThermalAutoThrottlingEnable":
case "StutterMode":
case "EnableAspmL0s":
case "EnableAspmL1":
case "DisableBlockWrite":
key.SetValue(valueName, enable ? 0 : 1, RegistryValueKind.DWord);
break;

case "DisableDMACopy":
case "DisableDrmdmaPowerGating":
case "DisableFBCSupport":
key.SetValue(valueName, enable ? 1 : 0, RegistryValueKind.DWord);
break;

case "Main3D":
case "FlipQueueSize":
case "ShaderCache":
case "VSyncControl":
case "CatalystAI":
case "TFQ":
byte[] newValue = enable ? new byte[] { 0x30, 0x00 } : new byte[] { 0x31, 0x00 };
key.SetValue(valueName, newValue, RegistryValueKind.Binary);
break;

case "ForceTripleBuffering":
case "PowerState":
case "Tessellation":
case "TextureOpt":
byte[] multiByteValue = enable ? new byte[] { 0x30, 0x00, 0x00, 0x00 } : new byte[] { 0x31, 0x00, 0x00, 0x00 };
key.SetValue(valueName, multiByteValue, RegistryValueKind.Binary);
break;

case "Main3D_DEF":
case "CatalystAI_DEF":
case "GLPBMode_DEF":
case "DisableFBCForFullScreenApp":
string stringValue = enable ? "0" : "1";
key.SetValue(valueName, stringValue, RegistryValueKind.String);
break;

default:
ShowError($"Unsupported registry value: '{valueName}'");
break;
// Handle values based on their expected types

switch (valueName)
{
// For DWORD values (Enable/Disable style values)
case "EnableUlps":
case "PP_ThermalAutoThrottlingEnable":
case "StutterMode":
case "EnableAspmL0s":
case "EnableAspmL1":
case "DisableBlockWrite":
case "DisableFBCSupport":
// Write 0 (off) or 1 (on)
key.SetValue(valueName, enable ? 0 : 1, RegistryValueKind.DWord);
break;

// For other DWORD values that follow the same behavior
case "DisableDMACopy":
case "DisableDrmdmaPowerGating":

// These values are inverted (1 = enabled, 0 = disabled)
key.SetValue(valueName, enable ? 1 : 0, RegistryValueKind.DWord);
break;

// For binary values (0x30/0x31 style for on/off)
case "Main3D":
case "FlipQueueSize":
case "ShaderCache":
case "VSyncControl":
case "CatalystAI":
case "TFQ":
// Binary: 0x30 is enabled, 0x31 is disabled
byte[] binaryValue = enable ? new byte[] { 0x30, 0x00 } : new byte[] { 0x31, 0x00 };
key.SetValue(valueName, binaryValue, RegistryValueKind.Binary);
break;

// For multi-byte binary values (e.g., 0x30, 0x00, 0x00, 0x00)
case "ForceTripleBuffering":
case "PowerState":
case "Tessellation":
case "TextureOpt":
// Multi-byte binary values, default to 0x30 or 0x31 with extra padding
byte[] multiByteValue = enable ? new byte[] { 0x30, 0x00, 0x00, 0x00 } : new byte[] { 0x31, 0x00, 0x00, 0x00 };
key.SetValue(valueName, multiByteValue, RegistryValueKind.Binary);
break;

// For string values (e.g., "0" = enabled, "1" = disabled)
case "Main3D_DEF":
case "CatalystAI_DEF":
case "GLPBMode_DEF":
case "DisableFBCForFullScreenApp":
// String: "0" means enabled, "1" means disabled
string stringValue = enable ? "0" : "1";
key.SetValue(valueName, stringValue, RegistryValueKind.String);
break;

default:
ShowError($"Unsupported registry value: '{valueName}'");
break;
}
}
catch (Exception ex)
{
// Handle any exceptions that occur while setting the registry value
ShowError($"Error setting registry value '{valueName}': {ex.Message}");
}
}

Expand All @@ -234,6 +266,8 @@ private void SetRegistryValue(RegistryKey key, string valueName, bool enable)





private void SwitchToVerifiedTab(object sender, RoutedEventArgs e)
{
VerifiedContent.Visibility = Visibility.Visible;
Expand Down
116 changes: 116 additions & 0 deletions src/BIOSMan.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<UserControl x:Class="NZTS_App.Views.BIOSMan"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:NZTS_App.Views"
Height="Auto" >
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Margin" Value="5"/>
</Style>

<Style TargetType="Button">
<Setter Property="Background" Value="#2C2F33"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Padding" Value="8,4"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="35"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Cursor" Value="Hand"/>
</Style>
</UserControl.Resources>

<Grid Background="#36393F" >
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0,15,0,35">

<!-- Custom Scrollbar -->
<ScrollViewer.Resources>
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollBar">
<Grid Background="Transparent" Margin="0,50,0,0">
<Track Name="PART_Track" IsDirectionReversed="true">
<Track.DecreaseRepeatButton>
<RepeatButton Name="PART_DecreaseButton"
Content=""
Command="ScrollBar.LineUpCommand"
Background="Transparent"
Width="0" Height="0"/>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Name="Thumb"
Background="Black"
Opacity="0.7"
Width="3"
MinHeight="200"/>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Name="PART_IncreaseButton"
Content=""
Command="ScrollBar.LineDownCommand"
Background="Transparent"
Width="0" Height="0"/>
</Track.IncreaseRepeatButton>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ScrollViewer.Resources>

<!-- Content Section -->
<StackPanel>
<ProgressBar Name="LoadingIndicator"
IsIndeterminate="True"
Visibility="Collapsed"
Height="4"
Margin="10"
Background="white"
Foreground="Red"/>
<!-- BIOS Information -->
<TextBlock Text="BIOS Manufacturer:" FontWeight="Bold"/>
<!-- Wrap TextBlock in Border for padding, border, and rounded corners -->
<Border Background="#2C2F33" Margin="10" Padding="8" BorderBrush="#7289DA" BorderThickness="0" CornerRadius="8">
<TextBlock Name="ManufacturerTextBlock" VerticalAlignment="Center"/>
</Border>

<TextBlock Text="BIOS Version:" FontWeight="Bold"/>
<Border Background="#2C2F33" Margin="10" Padding="8" BorderBrush="#7289DA" BorderThickness="0" CornerRadius="8">
<TextBlock Name="VersionTextBlock" VerticalAlignment="Center"/>
</Border>

<TextBlock Text="BIOS Serial Number:" FontWeight="Bold"/>
<Border Background="#2C2F33" Margin="10" Padding="8" BorderBrush="#7289DA" BorderThickness="0" CornerRadius="8">
<TextBlock Name="SerialNumberTextBlock" VerticalAlignment="Center"/>
</Border>

<TextBlock Text="BIOS Release Date:" FontWeight="Bold"/>
<Border Background="#2C2F33" Margin="10" Padding="8" BorderBrush="#7289DA" BorderThickness="0" CornerRadius="8">
<TextBlock Name="ReleaseDateTextBlock" VerticalAlignment="Center"/>
</Border>

<!-- DRAM Speed Info Display Section -->
<TextBlock Text="DRAM Speed (MHz):" FontWeight="Bold"/>
<Border Background="#2C2F33" Margin="10" Padding="8" BorderBrush="#7289DA" BorderThickness="0" CornerRadius="8">
<TextBlock Name="DRAMSpeedTextBlock" VerticalAlignment="Center"/>
</Border>

<!-- Processor Speed Info Display Section -->
<TextBlock Text="Processor Speed (MHz):" FontWeight="Bold"/>
<Border Background="#2C2F33" Margin="10" Padding="8" BorderBrush="#7289DA" BorderThickness="0" CornerRadius="8">
<TextBlock Name="ProcessorSpeedTextBlock" VerticalAlignment="Center"/>
</Border>

</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
Loading

0 comments on commit 4839071

Please sign in to comment.