text: // This is a personal academic project. Dear PVS-Studio, please check it.
  // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
  #include <naiveConsole.h>
  #include <video.h>
  
  static uint32_t uintToBase(uint64_t value, char *buffer, uint32_t base);
  
  static char buffer[64];
  static uint8_t *const video = (uint8_t *)0xB8000;
  static const uint32_t width = 80;
  static const uint32_t height = 25;
  
  void ncPrint(const char *string)
  {
  	for (int i = 0; string[i] != 0; i++)
  		ncPrintChar(string[i]);
  }
  
  /**
  * Prints a string with the given attribute. 
  * @params string: text to print
  *		  textColor: color of the text in binary format
  *		  backColor: color of the background in binary format
  **/
  void ncPrintAtt(const char *string, Color *textColor, Color *backColor)
  {
  	for (int i = 0; string[i] != 0; i++)
  		ncPrintCharAtt(string[i], textColor, backColor);
  }
  
  /**
  * Prints a letter with the default black background, white font.
  * @params character: character to print
  **/
  void ncPrintChar(char character)
  {
  	ncPrintCharAtt(character, &WHITE, &BLACK);
  }
  
  /**
  * Prints a letter with the given attribute.
  * It also checks if the pointer is going out of bounds and
  * moves everything one line up in that case.
  * @params character: letter to print
  **/
  
  void ncPrintCharAtt(char character, Color *fontColor, Color *backgroundColor)
  {
  	if (character == '\n')
  		newLine(backgroundColor);
  	else if (character == '\b')
  		eraseChar(backgroundColor);
  	else
  		drawChar(character, fontColor, backgroundColor);
  }
  
  void ncPrintDec(uint64_t value)
  {
  	ncPrintBase(value, 10);
  }
  
  void ncPrintHex(uint64_t value)
  {
  	ncPrintBase(value, 16);
  }
  
  void ncPrintBase(uint64_t value, uint32_t base)
  {
  	uintToBase(value, buffer, base);
  	ncPrint(buffer);
  }
  
  static uint32_t uintToBase(uint64_t value, char *buffer, uint32_t base)
  {
  	char *p = buffer;
  	char *p1, *p2;
  	uint32_t digits = 0;
  
  	// Calculate characters for each digit
  	do {
  		uint32_t remainder = value % base;
  		*p++ = (remainder < 10) ? remainder + '0' :
  					  remainder + 'A' - 10;
  		digits++;
  	} while (value /= base);
  
  	// Terminate string in buffer.
  	*p = 0;
  
  	// Reverse string in buffer.
  	p1 = buffer;
  	p2 = p - 1;
  	while (p1 < p2) {
  		char tmp = *p1;
  		*p1 = *p2;
  		*p2 = tmp;
  		p1++;
  		p2--;
  	}
  
  	return digits;
  }
  
  void ncNewline()
  {
  	newLine(&BLACK);
  }