Creando Stack viewer
This commit is contained in:
@@ -32,6 +32,8 @@ target_sources(
|
||||
UI/Disassembler.h
|
||||
UI/RegisterView.cpp
|
||||
UI/RegisterView.h
|
||||
UI/StackViewer.cpp
|
||||
UI/StackViewer.h
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE vendor)
|
||||
|
||||
@@ -287,6 +287,7 @@ void Interpreter::ret() const
|
||||
{
|
||||
this->machine_state->sp -= 1;
|
||||
this->machine_state->pc = this->machine_state->stack[this->machine_state->sp];
|
||||
this->machine_state->stack[this->machine_state->sp] = 0;
|
||||
}
|
||||
|
||||
void Interpreter::jp_addr(const Instruction& instruction) const
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
#include "CallbackManager.h"
|
||||
#include "../Graphics/Graphics.h"
|
||||
#include "../Interpreter/MachineState.h"
|
||||
|
||||
|
||||
struct MachineState;
|
||||
|
||||
class RegisterView
|
||||
{
|
||||
std::shared_ptr<Graphics> graphics;
|
||||
|
||||
34
src/UI/StackViewer.cpp
Normal file
34
src/UI/StackViewer.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "StackViewer.h"
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
StackViewer::StackViewer(
|
||||
std::shared_ptr<Graphics> graphics,
|
||||
std::shared_ptr<MachineState> machine_state,
|
||||
std::shared_ptr<CallbackManager> callback_manager
|
||||
) :
|
||||
graphics{std::move(graphics)},
|
||||
machine_state{std::move(machine_state)},
|
||||
callback_manager{std::move(callback_manager)}
|
||||
{
|
||||
}
|
||||
|
||||
void StackViewer::render()
|
||||
{
|
||||
if (ImGui::Begin("Chip8 - Stack"))
|
||||
{
|
||||
if (ImGui::BeginTable("Stack", 2, ImGuiTableFlags_BordersV))
|
||||
{
|
||||
for (std::size_t i = 0; i < std::size(machine_state->stack); i++)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("Depth %zu", i);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("0x%04X", machine_state->stack[i]);
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
25
src/UI/StackViewer.h
Normal file
25
src/UI/StackViewer.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef STACKVIEWER_H
|
||||
#define STACKVIEWER_H
|
||||
#include <memory>
|
||||
|
||||
#include "CallbackManager.h"
|
||||
#include "../Graphics/Graphics.h"
|
||||
#include "../Interpreter/MachineState.h"
|
||||
|
||||
class StackViewer
|
||||
{
|
||||
std::shared_ptr<Graphics> graphics;
|
||||
std::shared_ptr<MachineState> machine_state;
|
||||
std::shared_ptr<CallbackManager> callback_manager;
|
||||
|
||||
public:
|
||||
StackViewer(
|
||||
std::shared_ptr<Graphics> graphics,
|
||||
std::shared_ptr<MachineState> machine_state,
|
||||
std::shared_ptr<CallbackManager> callback_manager);
|
||||
|
||||
void render();
|
||||
};
|
||||
|
||||
|
||||
#endif //STACKVIEWER_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "MemoryViewer.h"
|
||||
#include "RegisterView.h"
|
||||
#include "RomInfo.h"
|
||||
#include "StackViewer.h"
|
||||
|
||||
UIManager::UIManager(
|
||||
std::shared_ptr<Graphics> graphics,
|
||||
@@ -23,7 +24,8 @@ UIManager::UIManager(
|
||||
disassembler{
|
||||
std::make_unique<Disassembler>(this->graphics, this->machine_state, this->interpreter, this->callback_manager)
|
||||
},
|
||||
register_view{std::make_unique<RegisterView>(this->graphics, this->machine_state, this->callback_manager)}
|
||||
register_view{std::make_unique<RegisterView>(this->graphics, this->machine_state, this->callback_manager)},
|
||||
stack_viewer{std::make_unique<StackViewer>(this->graphics, this->machine_state, this->callback_manager)}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,4 +37,5 @@ void UIManager::render()
|
||||
this->memory_viewer->render();
|
||||
this->disassembler->render();
|
||||
this->register_view->render();
|
||||
this->stack_viewer->render();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "MemoryViewer.h"
|
||||
#include "RegisterView.h"
|
||||
#include "RomInfo.h"
|
||||
#include "StackViewer.h"
|
||||
#include "../Graphics/Graphics.h"
|
||||
#include "../Interpreter/Interpreter.h"
|
||||
|
||||
@@ -24,6 +25,7 @@ class UIManager
|
||||
std::unique_ptr<MemoryViewer> memory_viewer;
|
||||
std::unique_ptr<Disassembler> disassembler;
|
||||
std::unique_ptr<RegisterView> register_view;
|
||||
std::unique_ptr<StackViewer> stack_viewer;
|
||||
|
||||
public:
|
||||
UIManager(
|
||||
|
||||
Reference in New Issue
Block a user