40 lines
667 B
C++
40 lines
667 B
C++
#ifndef CHIP8_H
|
|
#define CHIP8_H
|
|
#include <span>
|
|
|
|
#include "Graphics.h"
|
|
#include "Interpreter.h"
|
|
|
|
|
|
class Chip8 {
|
|
Graphics graphics;
|
|
Interpreter interpreter;
|
|
|
|
double target_cycle_time;
|
|
|
|
Uint64 last_update_time;
|
|
double accumulator;
|
|
|
|
std::span<const bool> keyboard_state;
|
|
bool run;
|
|
bool step;
|
|
|
|
void load_keyboard();
|
|
void execute_instructions();
|
|
void execute_instruction();
|
|
public:
|
|
Chip8();
|
|
|
|
bool init();
|
|
|
|
void update();
|
|
|
|
std::vector<uint8_t> read_rom(const std::string& path);
|
|
|
|
void set_keyboard_state(std::span<const bool> keyboard_state);
|
|
void on_keydown(SDL_Scancode scancode);
|
|
};
|
|
|
|
|
|
#endif //CHIP8_H
|