Added controller support

This commit is contained in:
Lauchmelder 2022-03-01 18:13:47 +01:00
parent e5cc1565fd
commit f4e6198a99
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
15 changed files with 310 additions and 6 deletions

View 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();
}

View 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;
};

View file

@ -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()