Files
CHIP-8/src/Machine.h
2025-06-28 21:14:07 -04:00

52 lines
1.1 KiB
C++

#ifndef MACHINE_H
#define MACHINE_H
#include "Sound.h"
#include "Graphics/Graphics.h"
#include "Interpreter/Interpreter.h"
#include "SDL3/SDL_events.h"
#include "UI/Display.h"
#include "UI/UIManager.h"
class Machine
{
std::shared_ptr<MachineState> machine_state;
std::shared_ptr<Graphics> graphics;
std::unique_ptr<Sound> sound;
std::shared_ptr<CallbackManager> callback_manager;
std::shared_ptr<Interpreter> interpreter;
std::unique_ptr<UIManager> ui_manager;
int ips;
uint64_t last_update_time;
double accumulator;
double target_cycle_time;
uint64_t last_timer_time;
double timer_accumulator;
double timer_cycle_time;
std::string rom;
bool running;
void execute_interpreter();
void update_timers();
void on_rom_load(const std::string& path);
void on_reset() const;
void on_stop();
void on_resume();
void on_step(int steps);
void on_speed_change(int ips);
void on_reload();
public:
void register_callbacks();
Machine();
void iterate();
bool on_event(const SDL_Event* event) const;
};
#endif //MACHINE_H