diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 14:49:20 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 14:49:20 +0100 |
| commit | 5959349f341a2380c0c3f41ec40a1e8e0d969d00 (patch) | |
| tree | 8b36ba3f8cade68562af1dfdcea8b42160619975 /lib/nes/common/display.hh | |
| parent | 1d32f7561305d6c86b1c80858bc73d55b1c6c402 (diff) | |
refactor: move emulation logic into sys
Diffstat (limited to 'lib/nes/common/display.hh')
| -rw-r--r-- | lib/nes/common/display.hh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/nes/common/display.hh b/lib/nes/common/display.hh new file mode 100644 index 0000000..ca78a85 --- /dev/null +++ b/lib/nes/common/display.hh @@ -0,0 +1,44 @@ +#pragma once + +#include "nes/common/rgb.hh" + +namespace nes +{ + class rgb; + + /// Abstraction of the display logic. + class display + { + public: + static constexpr auto width = unsigned{ 256 }; + static constexpr auto height = unsigned{ 240 }; + + virtual ~display() = default; + + display(display const&) = delete; + display(display&&) = delete; + auto operator=(display const&) -> display& = delete; + auto operator=(display&&) -> display& = delete; + + /// Switch between front and back buffers. + virtual auto switch_buffers() -> void = 0; + /// Update the pixel at the given position in the back buffer. + virtual auto set(unsigned x, unsigned y, rgb value) -> void = 0; + /// Load the pixel value at the given position in the back buffer. + virtual auto get(unsigned x, unsigned y) const -> rgb = 0; + /// Clear the entire back buffer with a color. + virtual auto clear(rgb const color) -> void + { + for (auto y = unsigned{ 0 }; y < height; ++y) + { + for (auto x = unsigned{ 0 }; x < width; ++x) + { + set(x, y, color); + } + } + } + + protected: + explicit display() = default; + }; +} // namespace nes
\ No newline at end of file |
