42 lines
839 B
C++
42 lines
839 B
C++
#ifndef CHIP8_DISPLAY_H
|
|
#define CHIP8_DISPLAY_H
|
|
|
|
#define STATE_ON 1
|
|
#define STATE_OFF 0
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
/**
|
|
* The display class used to handle drawing pixels to the SDL renderer
|
|
*/
|
|
class Display {
|
|
private:
|
|
/**
|
|
* Flag whether the display should be redrawn
|
|
*/
|
|
bool flagRedraw = false;
|
|
|
|
/**
|
|
* The 64x32-pixel monochrome display
|
|
*/
|
|
bool display[64 * 32] = {};
|
|
public:
|
|
/**
|
|
* Draws the current display to the SDL renderer
|
|
* @param renderer the SDL renderer to draw to
|
|
*/
|
|
void draw(SDL_Renderer* renderer);
|
|
|
|
/**
|
|
* Gets whether the display should be redrawn
|
|
* @return true if the display should be redrawn, false otherwise
|
|
*/
|
|
[[nodiscard]] bool needsRedraw() const;
|
|
|
|
/**
|
|
* Clears the display
|
|
*/
|
|
void clear();
|
|
};
|
|
#endif //CHIP8_DISPLAY_H
|