Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. // Debug stuffs
  2. #ifdef VERBOSE
  3.  
  4. #define CNS_LENGTH 2048
  5. static char console[CNS_LENGTH];
  6. static uint16_t cns_offs = 0;
  7.  
  8. void consolePrint(const char *format, ...){
  9.     char str[512] = { 0 };
  10.     va_list va;
  11.  
  12.     va_start(va, format);
  13.     vsnprintf(str, 512, format, va);
  14.     va_end(va);
  15.  
  16.     if (strlen(str) + cns_offs >= CNS_LENGTH) cns_offs = 0;
  17.     sprintf(&console[cns_offs], "%s\n", str);
  18.     cns_offs = strlen(console);
  19. }
  20.  
  21. void drawConsole(){
  22.     int y = 25;
  23.     char* text = strtok (console, "\n");
  24.     while (text != NULL){
  25.         if (y > 520){
  26.             y = 5;
  27.             cns_offs = 0;
  28.         }
  29.         drawString(5, y, text);
  30.         y += 20;
  31.         text = strtok(NULL, "\n");
  32.     }
  33. }
  34.  
  35. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement