Advertisement
Guest User

Untitled

a guest
Mar 6th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <memory>
  2. #include <cstdint>
  3.  
  4. const uintptr_t ADDRESS{0x40};
  5.  
  6. struct RGB {
  7.     uint8_t red{};
  8.     uint8_t green{};
  9.     uint8_t blue{};
  10. }
  11.  
  12. class Color {
  13.     std::unique_ptr<RGB> _rgb;
  14.    
  15. public:
  16.     Color(uintptr_t address): _rgb{reinterpret_cast<RGB*>{address}} {}
  17.  
  18.     void set_red(uint8_t value) {
  19.         _rgb->red = value;
  20.     }
  21.     void set_green(uint8_t value) {
  22.         _rgb->green = value;
  23.     }
  24.     void set_blue(uint8_t value) {
  25.         _rgb->blue = value;
  26.     }
  27. }
  28.  
  29. int main() {
  30.     Color color{ADDRESS};
  31.     color.set_red(255);
  32.     color.set_green(127);
  33.     color.set_blue(64);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement