Skip to content

Commit

Permalink
Make medium and high cpu levels configurable (#190) (#192)
Browse files Browse the repository at this point in the history
* Make medium and high cpu levels configurable (#190)

* Small layout fix in user.default.ini
  • Loading branch information
micheldebree committed May 26, 2024
1 parent 8773741 commit 0f7e69f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ SIDFactoryII/*.vcxproj.user
artifacts
xcuserdata
.ccls-cache
.cache
/SIDFactoryII/x64/Debug
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Please report issues in our [issue tracker](https://github.com/Chordian/sidfacto
![Commits since last
release](https://img.shields.io/github/commits-since/chordian/sidfactory2/release-20231002)

### Next release

- Added [#190](https://github.com/Chordian/sidfactory2/issues/190)
Configuration options
for setting the limits of rastertime usage used to color frames orange or red in
the flightrecorder.
`Visualizer.CPU.Medium.Rasterlines` and `Visualizer.CPU.High.Rasterlines`

### Build 20231002

- Added: [#102](https://github.com/Chordian/sidfactory2/issues/102) Visualizers
Expand Down
4 changes: 4 additions & 0 deletions SIDFactoryII/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Window.Scaling.Smooth = 1 // If you set this to 1, scaling
Visualizer.PulseWidth.Style = 0 // The way pulse width is visualized
// 0 = absolute value, 1 = alternative style
Visualizer.CPU.Medium.Rasterlines = 16 // In the flightrecorder, frames that use this many or more rasterlines get a warning color
Visualizer.CPU.High.Rasterlines = 24 // In the flightrecorder, frames that use this many or more rasterlines get an error color
//
// OVERLAY
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
#include "runtime/editor/cursor_control.h"
#include "runtime/environmentdefines.h"
#include "utils/usercolors.h"
#include "utils/config/configtypes.h"
#include "utils/configfile.h"
#include "utils/global.h"

#include "SDL_keycode.h"
#include "foundation/base/assert.h"

using namespace Foundation;
using namespace Utility;
using namespace Utility::Config;

namespace Editor
{
Expand All @@ -26,6 +30,9 @@ namespace Editor
{
FOUNDATION_ASSERT(inTextField != nullptr);
m_RequireRefresh = true;
ConfigFile& config = Global::instance().GetConfig();
m_CPUUsageMediumRasterlines = GetSingleConfigurationValue<ConfigValueInt>(config, "Visualizer.CPU.Medium.Rasterlines", 16);
m_CPUUsageHighRasterlines = GetSingleConfigurationValue<ConfigValueInt>(config, "Visualizer.CPU.High.Rasterlines", 24);
}


Expand Down Expand Up @@ -215,7 +222,7 @@ namespace Editor

const unsigned char scan_lines = static_cast<unsigned char>(frame_data.m_nCyclesSpend / EMULATION_CYCLES_PER_SCANLINE_PAL);

Color cycle_color = scan_lines < 0x10 ? color_cpu_usage_low : (scan_lines < 0x18 ? color_cpu_usage_medium : color_cpu_usage_high);
Color cycle_color = scan_lines < m_CPUUsageMediumRasterlines ? color_cpu_usage_low : (scan_lines < m_CPUUsageHighRasterlines ? color_cpu_usage_medium : color_cpu_usage_high);

m_TextField->PrintHexValue(x, y, is_uppercase, frame_number);
m_TextField->PrintChar(x + 4, y, ':');
Expand Down Expand Up @@ -256,4 +263,4 @@ namespace Editor
void ComponentFlightRecorder::ExecuteAction(int inActionInput)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "component_base.h"

#include <memory>
#include <string>
#include <functional>

namespace Foundation
{
Expand Down Expand Up @@ -42,5 +40,7 @@ namespace Editor
unsigned int m_CursorPos;
unsigned int m_MaxCursorPos;
unsigned int m_TopVisible;
unsigned int m_CPUUsageMediumRasterlines;
unsigned int m_CPUUsageHighRasterlines;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#include "foundation/graphics/drawfield.h"
#include "runtime/editor/datasources/datasource_flightrecorder.h"
#include "runtime/environmentdefines.h"
#include "utils/global.h"
#include "utils/config/configtypes.h"
#include "utils/configfile.h"
#include "utils/usercolors.h"

using namespace Foundation;
using namespace Utility;
using namespace Utility::Config;

namespace Editor
{
Expand All @@ -23,6 +27,10 @@ namespace Editor
, m_DataSource(inDataSource)
{

ConfigFile& config = Global::instance().GetConfig();
m_CPUUsageMediumRasterlines = GetSingleConfigurationValue<ConfigValueInt>(config, "Visualizer.CPU.Medium.Rasterlines", 16);
m_CPUUsageHighRasterlines = GetSingleConfigurationValue<ConfigValueInt>(config, "Visualizer.CPU.High.Rasterlines", 24);

}


Expand Down Expand Up @@ -62,12 +70,7 @@ namespace Editor

const auto fetch_cycle_color = [&](const int inValue) -> const Color
{
if (inValue < 0x10)
return color_cpu_usage_low;
if (inValue < 0x18)
return color_cpu_usage_medium;

return color_cpu_usage_high;
return inValue < m_CPUUsageMediumRasterlines ? color_cpu_usage_low : (inValue < m_CPUUsageHighRasterlines ? color_cpu_usage_medium : color_cpu_usage_high);
};

DrawColoredFilled(fetch_cycle_value, fetch_cycle_color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ namespace Editor
);

std::shared_ptr<DataSourceFlightRecorder> m_DataSource;

unsigned int m_CPUUsageMediumRasterlines;
unsigned int m_CPUUsageHighRasterlines;
};
}
}
4 changes: 4 additions & 0 deletions dist/documentation/user.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Window.Scaling.Smooth = 1 // If you set this to 1, scaling
Visualizer.PulseWidth.Style = 0 // The way pulse width is visualized
// 0 = absolute value, 1 = alternative style


Visualizer.CPU.Medium.Rasterlines = 16 // In the flightrecorder, frames that use this many or more rasterlines get a warning color
Visualizer.CPU.High.Rasterlines = 24 // In the flightrecorder, frames that use this many or more rasterlines get an error color
O
//
// OVERLAY
//
Expand Down

0 comments on commit 0f7e69f

Please sign in to comment.