Advertisement
Guest User

Untitled

a guest
Aug 1st, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | Source Code | 0 0
  1. void Console::PutCharExt(unsigned char c, int fore_color, int back_color)
  2. {
  3.     uint8_t chr = (uint8_t)c;
  4.     if (c == '\n')
  5.     {
  6.         this->cursor_y += 1;
  7.         this->cursor_x = 0;
  8.     }
  9.     else if (c == '\r')
  10.     {
  11.         this->cursor_x = 0;
  12.     }
  13.     else if (c == '\b')
  14.     {
  15.         if (this->cursor_x <= 0)
  16.         {
  17.             this->cursor_y -= 1;
  18.             this->cursor_x = this->console_w - 1;
  19.         }
  20.         else
  21.         {
  22.             this->cursor_x -= 1;
  23.         }
  24.     }
  25.     else if (c == '\7')
  26.     {
  27.         this->PlayBell();
  28.     }
  29.     else if (c == '\t')
  30.     {
  31.         int n = 8 - (this->cursor_x % 8);
  32.         for (int i = 0; i < n; i++)
  33.         {
  34.             /* Don't exceed beyond screen width */
  35.             this->PutCharExt(' ', fore_color, back_color);
  36.         }
  37.     }
  38.     else
  39.     {
  40.         this->PlaceChar(this->cursor_x, this->cursor_y, chr, fore_color, back_color);
  41.         /* Set cursor shadow, this is what creates the cursor "burn in" effect */
  42.         this->cursor_shadow_width = this->font_w * 2;
  43.         this->cursor_x += 1;
  44.     }
  45.  
  46.     /* Wrap around */
  47.     if (this->cursor_x >= this->console_w)
  48.     {
  49.         if (this->wrap_around)
  50.         {
  51.             this->cursor_x = 0;
  52.             this->cursor_y += 1;
  53.         }
  54.         else
  55.         {
  56.             this->cursor_x--;
  57.         }
  58.     }
  59.  
  60.     if (this->cursor_y >= this->console_h)
  61.     {
  62.         while(!(this->cursor_y < this->console_h))
  63.             this->Scroll();
  64.     }
  65.  
  66.     /* Keep cursor in bounds */
  67.     this->LimitCursor();
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement