Advertisement
Guest User

Untitled

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