24 std::vector<u8> rom_bytes;
35 void set_mmu(
MMU* m) { mmu = m; }
37 void set_rom_info(
const RomInfo& info) { romInfo = info; }
38 void step(
int cycles);
39 u8 read(u16 address)
const;
40 void write(u16 address, u8 value);
42 const u32* get_framebuffer()
const {
return framebuffer.data(); }
43 bool is_frame_ready()
const {
return frame_ready; }
44 void clear_frame_ready() { frame_ready =
false; }
47 void init_window(
bool debug,
const std::string& rom_title,
bool fullscreen =
false);
49 bool isPaused()
const {
return paused; }
50 void handleEvents(JoypadState& joypad);
51 void update(
float dtSeconds, u64 cyclesExecuted);
54 void recordOpcode(u16 pc, u8 opcode);
55 void checkBreakpoint(u16 pc);
57 bool isStepRequested()
const {
return stepRequested; }
58 void clearStepRequest() { stepRequested =
false; }
60 bool isTurbo()
const {
return turbo; }
61 void setTurbo(
bool val) { turbo = val; }
62 int getActiveSlot()
const {
return activeSlot; }
63 void setActiveSlot(
int slot) { activeSlot = slot; }
65 bool isResetRequested()
const {
return resetRequested; }
66 void clearResetRequest() { resetRequested =
false; }
69 bool saveStateSlot(
int slot);
70 bool loadStateSlot(
int slot);
71 bool saveStatePath(
const std::string& filepath);
72 bool loadStatePath(
const std::string& filepath);
75 void drawText(
const sf::Vector2f& pos,
const std::string& text,
unsigned size,
const sf::Color& color);
76 std::string toHex(u32 value,
int width)
const;
79 std::unique_ptr<InterruptController> dummy_ic;
80 InterruptController& ic;
81 ProcessingUnit* cpu =
nullptr;
86 sf::RenderWindow window;
88 bool fontLoaded{
false};
89 bool debugMode{
false};
91 sf::Texture screenTexture;
92 sf::Sprite screenSprite;
95 std::array<u8, 0x2000> vram{};
96 std::array<u8, 160> oam{};
112 u8 window_line_counter = 0;
113 bool frame_ready =
false;
114 std::array<u32, 160 * 144> framebuffer{};
123 Mode get_mode()
const {
return static_cast<Mode
>(stat & 0x03); }
124 void set_mode(Mode mode);
127 void render_scanline();
128 void render_sprites();
129 u32 get_color(u8 color_id, u16 palette_address)
const;
132 std::deque<OpcodeTrace> opcodeLog;
133 std::vector<u16> breakpoints;
135 bool stepRequested{
false};
138 bool resetRequested{
false};
139 std::string externalStatePath;
140 JoypadState clickableJoypad{};
141 JoypadState physicalJoypad{};
142 JoypadState currentJoypadState{};
144 float timeAccumulator{0.0f};
149 std::string statusMessage;
150 float statusTimer{0.0f};