started work on sprite rendering

This commit is contained in:
Lauchmelder 2022-03-06 23:31:52 +01:00
parent 6fe829d66c
commit ca729613c7
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
10 changed files with 417 additions and 22 deletions

View file

@ -10,6 +10,7 @@
#include "Disassembler.hpp"
#include "MemoryViewer.hpp"
#include "NametableViewer.hpp"
#include "OAMViewer.hpp"
#include "PatternTableViewer.hpp"
#include "ControllerPortViewer.hpp"
#include "Palettes.hpp"
@ -27,6 +28,7 @@ Debugger::Debugger(Bus* bus) :
windows.push_back(new MemoryViewer(this, bus));
windows.push_back(new NametableViewer(this, bus));
windows.push_back(new OAMViewer(this, &bus->ppu));
windows.push_back(new PatternTableViewer(this, bus->cartridge.GetMapper()));
windows.push_back(new ControllerPortViewer(this, &bus->controllerPort));
windows.push_back(new Palettes(this, bus));

View file

@ -0,0 +1,33 @@
#include "OAMViewer.hpp"
#include "../PPU.hpp"
#include <imgui/imgui.h>
OAMViewer::OAMViewer(Debugger* debugger, PPU* ppu) :
DebugWindow("OAM Viewer", debugger), ppu(ppu)
{
}
void OAMViewer::OnRender()
{
if (!ImGui::Begin("OAM Viewer", &isOpen))
{
ImGui::End();
return;
}
char label[sizeof("Sprite 00")];
for (int i = 0; i < 64; i++)
{
std::sprintf(label, "Sprite %02d", i);
if (ImGui::CollapsingHeader(label))
{
ImGui::Text("Y pos : %02X", ppu->OAM[4 * i + 0]);
ImGui::Text("Tile : %02X", ppu->OAM[4 * i + 1]);
ImGui::Text("Attribute: %02X", ppu->OAM[4 * i + 2]);
ImGui::Text("X pos : %02X", ppu->OAM[4 * i + 3]);
}
}
ImGui::End();
}

View file

@ -0,0 +1,17 @@
#pragma once
#include "DebugWindow.hpp"
class PPU;
class OAMViewer :
public DebugWindow
{
public:
OAMViewer(Debugger* debugger, PPU* ppu);
virtual void OnRender() override;
private:
PPU* ppu;
};

View file

@ -121,6 +121,11 @@ void PPUWatcher::OnRender()
ImGui::TableNextColumn();
ImGui::Text("$%04X", ppu->ppuctrl.Flag.BackgrPatternTableAddr ? 0x1000 : 0x0000);
ImGui::TableNextColumn();
ImGui::Text("Sprite Size");
ImGui::TableNextColumn();
ImGui::Text(ppu->ppuctrl.Flag.SpriteSize ? "8x16" : "8x8");
ImGui::TableNextColumn();
ImGui::Text("Master/Slave");
ImGui::TableNextColumn();