-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added interrupt I_STAT and I_MASK plots
- Loading branch information
Showing
7 changed files
with
3,888 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include "InterruptMenu.hpp" | ||
#include "imgui.h" | ||
#include "imgui_impl_glfw.h" | ||
#include "imgui_impl_opengl3.h" | ||
#include "implot.h" | ||
#include "SystemControlCoprocessor.hpp" | ||
#include "Psx.hpp" | ||
#include "Cpu.hpp" | ||
|
||
InterruptMenu::InterruptMenu(std::shared_ptr<Psx> _psx) : DebugMenu(_psx) | ||
{ | ||
|
||
} | ||
|
||
void InterruptMenu::draw_in_category(menubar_category category) | ||
{ | ||
if (category == menubar_category::VIEW) | ||
{ | ||
ImGui::Checkbox("Show Interrupts", &is_visible); | ||
} | ||
} | ||
|
||
void InterruptMenu::draw_menu() | ||
{ | ||
if (is_visible == false) | ||
{ | ||
return; | ||
} | ||
|
||
ImGui::Begin("Interrupt"); | ||
ImGui::Text("I_STAT"); | ||
for (int idx = 0; idx < NUM_IRQS; idx++) | ||
{ | ||
ImGui::PlotLines(std::to_string(idx).c_str(), | ||
[](void *data, int idx) { | ||
std::deque<float> * values = static_cast<std::deque<float>*>(data); | ||
if (static_cast<unsigned int>(idx) < values->size()) | ||
{ | ||
return (*values)[idx]; | ||
} | ||
else | ||
{ | ||
return 0.f; | ||
} | ||
}, | ||
reinterpret_cast<void*>(&i_stat_irqs[idx]), MAX_VALUE_COUNT, 0, 0, 0.f, 1.f); | ||
} | ||
|
||
ImGui::Text("I_MASK"); | ||
for (int idx = 0; idx < NUM_IRQS; idx++) | ||
{ | ||
ImGui::PlotLines(std::to_string(idx).c_str(), | ||
[](void *data, int idx) { | ||
std::deque<float> * values = static_cast<std::deque<float>*>(data); | ||
if (static_cast<unsigned int>(idx) < values->size()) | ||
{ | ||
return (*values)[idx]; | ||
} | ||
else | ||
{ | ||
return 0.f; | ||
} | ||
}, | ||
reinterpret_cast<void*>(&i_mask_irqs[idx]), MAX_VALUE_COUNT, 0, 0, 0.f, 1.f); | ||
} | ||
ImGui::End(); | ||
} | ||
|
||
void InterruptMenu::tick() | ||
{ | ||
if (is_visible == false) | ||
{ | ||
return; | ||
} | ||
|
||
system_control::interrupt_register i_stat = psx->cpu->cop0->interrupt_status_register; | ||
system_control::interrupt_register i_mask = psx->cpu->cop0->interrupt_mask_register; | ||
|
||
unsigned int i_stat_bits = i_stat.IRQ_BITS; | ||
unsigned int i_mask_bits = i_mask.IRQ_BITS; | ||
for (int idx = 0; idx < NUM_IRQS; idx++) | ||
{ | ||
bool i_stat_for_idx = i_stat_bits & 0x1; | ||
bool i_mask_for_idx = i_mask_bits & 0x1; | ||
|
||
i_stat_irqs[idx].push_back(i_stat_for_idx ? 1.f : 0.f); | ||
i_mask_irqs[idx].push_back(i_mask_for_idx ? 1.f : 0.f); | ||
|
||
if (i_stat_irqs[idx].size() > MAX_VALUE_COUNT) | ||
{ | ||
// can pop both as they will have the exact same size | ||
i_stat_irqs[idx].pop_front(); | ||
i_mask_irqs[idx].pop_front(); | ||
} | ||
|
||
// shift to next irq bit to check | ||
i_stat_bits >>= 1; | ||
i_mask_bits >>= 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include "DebugMenuManager.hpp" | ||
#include <deque> | ||
|
||
class InterruptMenu : public DebugMenu | ||
{ | ||
public: | ||
InterruptMenu(std::shared_ptr<Psx> _psx); | ||
|
||
virtual void draw_in_category(menubar_category category) final; | ||
virtual void draw_menu() final; | ||
virtual void tick() final; | ||
|
||
private: | ||
bool is_visible = false; | ||
|
||
static const int MAX_VALUE_COUNT = 1000; | ||
static const int NUM_IRQS = 11; | ||
|
||
std::deque<float> i_stat_irqs[NUM_IRQS]; | ||
std::deque<float> i_mask_irqs[NUM_IRQS]; | ||
|
||
}; |
Oops, something went wrong.