Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct __attribute__((packed)) VideoChar { char c; char color; };
- struct VideoChar * video = (struct VideoChar*) 0xb8000;
- int x = 0;
- int y = 0;
- void clearScreen(void)
- {
- struct VideoChar vchar;
- vchar.c = ' ';
- vchar.color = 0x0f;
- for(int i = 0; i <= 2000; i++)
- {
- video[i] = vchar;
- }
- }
- void puts(const char * string)
- {
- for (int i = 0; string[i] != 0; i++)
- {
- struct VideoChar vchar;
- vchar.c = string[i];
- vchar.color = 0x0f;
- video[x + 80 * y] = vchar;
- x++;
- }
- if (y == 24 || x / 80 >= 24)
- scroll();
- }
- void putc(char c)
- {
- struct VideoChar vchar;
- vchar.c = c;
- vchar.color = 0x0f;
- video[x + 80 * y] = vchar;
- x++;
- }
- void scroll(void)
- {
- for (int y = 0; y < 24; y++)
- {
- for (int x = 0; x < 80; x++)
- {
- video[x + 80 * y] = video[x + 80 * (y + 1)];
- }
- }
- }
- int int_to_string(char * buffer, size_t length, int number, int base)
- {
- if (base >= 2 && base <= 16)
- {
- int i = 0;
- const char * Digits = "0123456789ABCDEF";
- if (number > 0)
- {
- number = -number;
- buffer[0] = '-';
- i = 1;
- }
- for (i = i; number > 0; i++)
- {
- buffer[i] = Digits[number % base];
- number /= base;
- }
- puts(buffer);
- return i;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement