Added controller support
This commit is contained in:
parent
e5cc1565fd
commit
f4e6198a99
15 changed files with 310 additions and 6 deletions
58
src/debugger/ControllerPortViewer.cpp
Normal file
58
src/debugger/ControllerPortViewer.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "ControllerPortViewer.hpp"
|
||||
|
||||
#include "../ControllerPort.hpp"
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
ControllerPortViewer::ControllerPortViewer(Debugger* parent, ControllerPort* controllerPort) :
|
||||
DebugWindow("Controller Port Viewer", parent), controllerPort(controllerPort)
|
||||
{
|
||||
}
|
||||
|
||||
void ControllerPortViewer::OnRender()
|
||||
{
|
||||
if (!ImGui::Begin(title.c_str(), &isOpen))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::Text("Latch : %02X", controllerPort->latch.Raw);
|
||||
ImGui::Text("Controller port: %d", controllerPort->latch.Ports.Controller);
|
||||
ImGui::Text("Expansion port : %d", controllerPort->latch.Ports.Expansion);
|
||||
|
||||
int counter = 1;
|
||||
for (Controller* controller : controllerPort->connectedDevices)
|
||||
{
|
||||
if (controller == nullptr)
|
||||
continue;
|
||||
|
||||
std::string controllerName = "Controller " + std::to_string(counter);
|
||||
if (ImGui::CollapsingHeader(controllerName.c_str(), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::Text("Output Line: D%d", controller->outPin);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::InputScalar("Shift Register", ImGuiDataType_U8, &controller->outRegister, (const void*)0, (const void*)0, "%02X", ImGuiInputTextFlags_CharsHexadecimal);
|
||||
|
||||
if (ImGui::BeginTable(controllerName.c_str(), 8))
|
||||
{
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d", i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d", (controller->outRegister >> i) & 0x1);
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
17
src/debugger/ControllerPortViewer.hpp
Normal file
17
src/debugger/ControllerPortViewer.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "DebugWindow.hpp"
|
||||
|
||||
class ControllerPort;
|
||||
|
||||
class ControllerPortViewer :
|
||||
public DebugWindow
|
||||
{
|
||||
public:
|
||||
ControllerPortViewer(Debugger* parent, ControllerPort* controllerPort);
|
||||
|
||||
virtual void OnRender() override;
|
||||
|
||||
private:
|
||||
ControllerPort* controllerPort;
|
||||
};
|
|
@ -10,6 +10,7 @@
|
|||
#include "Disassembler.hpp"
|
||||
#include "MemoryViewer.hpp"
|
||||
#include "NametableViewer.hpp"
|
||||
#include "ControllerPortViewer.hpp"
|
||||
|
||||
Debugger::Debugger(Bus* bus) :
|
||||
bus(bus)
|
||||
|
@ -20,6 +21,7 @@ Debugger::Debugger(Bus* bus) :
|
|||
windows.push_back(disassembler);
|
||||
windows.push_back(new MemoryViewer(this, bus));
|
||||
windows.push_back(new NametableViewer(this, bus));
|
||||
windows.push_back(new ControllerPortViewer(this, &bus->controllerPort));
|
||||
}
|
||||
|
||||
Debugger::~Debugger()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue