Create Emulator class for GUI with nav bar
This commit is contained in:
83
src/app/core/emulator.cc
Normal file
83
src/app/core/emulator.cc
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#include "app/core/emulator.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "app/core/constants.h"
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace core {
|
||||||
|
|
||||||
|
void Emulator::Run() {
|
||||||
|
// Initialize the emulator if a ROM is loaded
|
||||||
|
if (!snes_.running()) {
|
||||||
|
if (rom()->isLoaded()) {
|
||||||
|
snes_.Init(*rom());
|
||||||
|
running_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render the emulator output
|
||||||
|
RenderNavBar();
|
||||||
|
|
||||||
|
RenderEmulator();
|
||||||
|
|
||||||
|
while (running_) {
|
||||||
|
// Handle user input events
|
||||||
|
HandleEvents();
|
||||||
|
// Update the emulator state
|
||||||
|
UpdateEmulator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulator::RenderEmulator() {
|
||||||
|
// Get the emulator output and render it to the child window
|
||||||
|
// You can use the ImGui::Image function to display the emulator output as a
|
||||||
|
// texture
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulator::RenderNavBar() {
|
||||||
|
MENU_BAR()
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Game")) {
|
||||||
|
MENU_ITEM("Pause") {}
|
||||||
|
MENU_ITEM("Reset") {}
|
||||||
|
MENU_ITEM("Power Off") {}
|
||||||
|
MENU_ITEM("Save State") {}
|
||||||
|
MENU_ITEM("Load State") {}
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Debug")) {
|
||||||
|
MENU_ITEM("Debugger") {}
|
||||||
|
MENU_ITEM("Memory Viewer") {}
|
||||||
|
MENU_ITEM("Tile Viewer") {}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Options")) {
|
||||||
|
MENU_ITEM("Audio") {}
|
||||||
|
MENU_ITEM("Input") {}
|
||||||
|
MENU_ITEM("Video") {}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
END_MENU_BAR()
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulator::HandleEvents() {
|
||||||
|
// Handle user input events
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulator::UpdateEmulator() {
|
||||||
|
// Update the emulator state (CPU, PPU, APU, etc.)
|
||||||
|
// ...
|
||||||
|
snes_.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace core
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
42
src/app/core/emulator.h
Normal file
42
src/app/core/emulator.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef YAZE_APP_CORE_EMULATOR_H
|
||||||
|
#define YAZE_APP_CORE_EMULATOR_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "app/emu/snes.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace core {
|
||||||
|
|
||||||
|
class Emulator : public SharedROM {
|
||||||
|
public:
|
||||||
|
// Runs the emulator loop, including event handling and rendering
|
||||||
|
void Run();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Renders the emulator output to an ImGui child window
|
||||||
|
void RenderEmulator();
|
||||||
|
|
||||||
|
// Draws the navigation bar with various controls
|
||||||
|
void RenderNavBar();
|
||||||
|
|
||||||
|
// Handles user input events
|
||||||
|
void HandleEvents();
|
||||||
|
|
||||||
|
// Updates the emulator state (CPU, PPU, APU, etc.)
|
||||||
|
void UpdateEmulator();
|
||||||
|
|
||||||
|
// Member variables to store internal state and resources
|
||||||
|
emu::SNES snes_;
|
||||||
|
|
||||||
|
bool running_ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace core
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif // YAZE_APP_CORE_EMULATOR_H
|
||||||
Reference in New Issue
Block a user