Colours
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
VGAChar_t* framebuffer = (VGAChar_t*)0xB8000;
|
||||
|
||||
void putchar(int x, int y, char c, char foreground, char background) {
|
||||
void putcar(int x, int y, char c, char foreground, char background) {
|
||||
framebuffer[(y * TERM_WIDTH) + x].c = c;
|
||||
framebuffer[(y * TERM_WIDTH) + x].foreground = foreground;
|
||||
framebuffer[(y * TERM_WIDTH) + x].background = background;
|
||||
|
||||
@@ -7,4 +7,4 @@ struct VGAChar_t {
|
||||
char background:4;
|
||||
}__attribute__((packed));
|
||||
|
||||
void putchar(int x, int y, char c, char foreground, char background);
|
||||
void putcar(int x, int y, char c, char foreground, char background);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "terminal.h"
|
||||
|
||||
#include <kernel/kernio.h>
|
||||
|
||||
static const int TERMINAL_WIDTH = 80;
|
||||
static const int TERMINAL_HEIGHT = 24;
|
||||
|
||||
static char* frameBuffer = (char*)0xB8000;
|
||||
|
||||
static char clearColour = 0x0;
|
||||
static char bgColour = 0x0;
|
||||
static char fgColour = 0xF;
|
||||
|
||||
struct Cursor {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} __attribute__((packed));
|
||||
|
||||
Cursor cursor;
|
||||
|
||||
void cls() {
|
||||
for (uint8_t x = 0; x < TERMINAL_WIDTH; x++) {
|
||||
for (uint8_t y = 0; y < TERMINAL_HEIGHT; y++) {
|
||||
frameBuffer[x + TERMINAL_WIDTH * y] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
moveCursor(0,0);
|
||||
}
|
||||
|
||||
void putchar(char input) {
|
||||
|
||||
}
|
||||
|
||||
void write(char* input) {
|
||||
|
||||
}
|
||||
|
||||
void writeln(char* input) {
|
||||
write(input);
|
||||
nline();
|
||||
}
|
||||
|
||||
void nline() {
|
||||
|
||||
}
|
||||
|
||||
void setClearColour(char col) {
|
||||
clearColour = col;
|
||||
}
|
||||
|
||||
void showCursor() {
|
||||
outb(0x3D4, 0x0A);
|
||||
outb(0x3D5, (inb(0x3D5) & 0xC0) | 1);
|
||||
|
||||
outb(0x3D4, 0x0B);
|
||||
outb(0x3D5, (inb(0x3D5) & 0xE0) | 1);
|
||||
}
|
||||
|
||||
void hideCursor() {
|
||||
outb(0x3D4, 0x0A);
|
||||
outb(0x3D5, 0x20);
|
||||
}
|
||||
|
||||
void moveCursor(int x, int y) {
|
||||
uint16_t pos = y * TERMINAL_WIDTH + x;
|
||||
|
||||
outb(0x3D4, 0x0F);
|
||||
outb(0x3D5, (uint8_t) (pos & 0xFF));
|
||||
outb(0x3D4, 0x0E);
|
||||
outb(0x3D5, (uint8_t) ((pos >> 8) & 0xFF));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,37 @@
|
||||
#include <kernel/drivers/VGA/vga.h>
|
||||
#include <lib/std/string.h>
|
||||
#include <lib/stdint.h>
|
||||
|
||||
void clear();
|
||||
template <typename T>
|
||||
void print(T input);
|
||||
enum {
|
||||
BLACK = 0x0,
|
||||
BLUE = 0x1,
|
||||
GREEN = 0x2,
|
||||
CYAN = 0x3,
|
||||
RED = 0x4,
|
||||
MAGENTA = 0x5,
|
||||
BROWN = 0x6,
|
||||
GREY = 0x7,
|
||||
DARK_GREY = 0x8,
|
||||
BRIGHT_BLUE = 0x9,
|
||||
BRIGHT_GREEN = 0xA,
|
||||
BRIGHT_CYAN = 0xB,
|
||||
BRIGHT_RED = 0xC,
|
||||
BRIGHT_MAGENTA = 0xD,
|
||||
YELLOW = 0xE,
|
||||
WHITE = 0xF,
|
||||
};
|
||||
|
||||
void cls();
|
||||
|
||||
void putchar(char input);
|
||||
|
||||
void write(char* input);
|
||||
void writeln(char* input);
|
||||
|
||||
void nline();
|
||||
|
||||
void setClearColour(char col);
|
||||
|
||||
void showCursor();
|
||||
void hideCursor();
|
||||
|
||||
void moveCursor(int x, int y);
|
||||
|
||||
@@ -1,13 +1 @@
|
||||
#include "kernio.h"
|
||||
|
||||
inline void outb(uint16_t port, uint8_t b) {
|
||||
asm("outb %0, %1" : : "a"(b), "Nd"(port));
|
||||
}
|
||||
|
||||
inline uint8_t inb(uint16_t port) {
|
||||
uint8_t ret;
|
||||
asm volatile ( "inb %1, %0"
|
||||
: "=a"(ret) // Output
|
||||
: "Nd"(port)); // Input
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
#include <lib/stdint.h>
|
||||
|
||||
inline void outb(uint16_t port, uint8_t b);
|
||||
inline uint8_t inb(uint16_t port);
|
||||
inline void outb(uint16_t port, uint8_t b) {
|
||||
asm("outb %0, %1" : : "a"(b), "Nd"(port));
|
||||
}
|
||||
|
||||
inline uint8_t inb(uint16_t port) {
|
||||
uint8_t ret;
|
||||
asm ( "inb %1, %0"
|
||||
: "=a"(ret) // Output
|
||||
: "Nd"(port)); // Input
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user