Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added max cycle and rasterline in flightrecorder #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ release](https://img.shields.io/github/commits-since/chordian/sidfactory2/releas

### Next release

- Added [#190](https://github.com/Chordian/sidfactory2/issues/190)
- 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`
- Added: [#117](https://github.com/Chordian/sidfactory2/issues/117)
Flightrecorder now shows max cycles and rasterlines used over time, above
the column that shows cycle and rasterline counts for each frame.

### Build 20231002

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "foundation/graphics/textfield.h"
#include "foundation/input/mouse.h"
#include "foundation/input/keyboard.h"
#include "foundation/input/keyboard_utils.h"
#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 "utils/usercolors.h"

#include "SDL_keycode.h"
#include "foundation/base/assert.h"
Expand Down Expand Up @@ -209,6 +209,13 @@ namespace Editor

const int x = 2;

const unsigned short max_cycles = static_cast<unsigned short>((*m_DataSource).GetCyclesSpendMax());
const unsigned char max_scan_lines = static_cast<unsigned char>(max_cycles / EMULATION_CYCLES_PER_SCANLINE_PAL);

Color max_color = max_scan_lines < m_CPUUsageMediumRasterlines ? color_cpu_usage_low : (max_scan_lines < m_CPUUsageHighRasterlines ? color_cpu_usage_medium : color_cpu_usage_high);
m_TextField->PrintHexValue(x + 6, 2, max_color, is_uppercase, max_cycles);
m_TextField->PrintHexValue(x + 11, 2, max_color, is_uppercase, max_scan_lines);

for (int i = 0; i < visible_row_count; ++i)
{
const int y = i + 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@ namespace Editor

return index;
}

const unsigned int DataSourceFlightRecorder::GetCyclesSpendMax() const
{
FOUNDATION_ASSERT(m_FlightRecorder != nullptr);
return m_FlightRecorder->CyclesSpendMax();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Editor
const int GetSize() const override;
const bool IsRecording() const;
const unsigned int GetNewestRecordingIndex() const;
const unsigned int GetCyclesSpendMax() const;

bool PushDataToSource() override { return true; }

Expand Down
11 changes: 11 additions & 0 deletions SIDFactoryII/source/runtime/execution/flightrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace Emulation

m_TopIndex = 0;
m_RecordedFrameCount = 0;
m_CyclesSpendMax = 0;

for (unsigned int i = 0; i < m_FrameCapacity; ++i)
m_Frames[i].Reset();
Expand Down Expand Up @@ -124,6 +125,12 @@ namespace Emulation
return m_RecordedFrameCount;
}

unsigned int FlightRecorder::CyclesSpendMax() const
{
FOUNDATION_ASSERT(m_Locked);
return m_CyclesSpendMax;
}

//------------------------------------------------------------------------------------------------

const FlightRecorder::Frame& FlightRecorder::GetFrame(unsigned int inIndex) const
Expand Down Expand Up @@ -154,6 +161,10 @@ namespace Emulation
inFrameData.m_nFrameNumber = inFrame;
inFrameData.m_nCyclesSpend = inCyclesSpend;

if (inCyclesSpend > m_CyclesSpendMax) {
m_CyclesSpendMax = inCyclesSpend;
}

inMemory->GetData(0xd400, &inFrameData.m_SIDData, 0x19);

inFrameData.m_TempoCounter = (*inMemory)[m_DriverTempoCounterAddress];
Expand Down
2 changes: 2 additions & 0 deletions SIDFactoryII/source/runtime/execution/flightrecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace Emulation
void Record(unsigned int inFrame, CPUMemory* inMemory, unsigned int inCyclesSpend);

unsigned int RecordedFrameCount() const;
unsigned int CyclesSpendMax() const;
const Frame& GetFrame(unsigned int inIndex) const;
const Frame& GetNewestFrame() const;

Expand All @@ -69,6 +70,7 @@ namespace Emulation

unsigned int m_TopIndex;
unsigned int m_RecordedFrameCount;
unsigned int m_CyclesSpendMax;

unsigned int m_FrameCapacity;

Expand Down