2024-04-09 23:46:56 +08:00
|
|
|
#ifndef CPOS_VGA_H
|
|
|
|
#define CPOS_VGA_H
|
|
|
|
|
2024-04-11 23:32:28 +08:00
|
|
|
#include "printf.h"
|
2024-04-12 22:03:07 +08:00
|
|
|
#include "multiboot.h"
|
2024-04-09 23:46:56 +08:00
|
|
|
|
2024-04-11 22:53:15 +08:00
|
|
|
/*
|
|
|
|
* \032 DARK GRAY
|
|
|
|
* \033 LIGHT RED
|
|
|
|
* \034 LIGHT BLUE
|
|
|
|
* \035 LIGHT GREEN
|
|
|
|
* \036 LIGHT GRAY
|
|
|
|
* \037 LIGHT CYAN
|
|
|
|
*/
|
|
|
|
|
2024-04-10 01:18:08 +08:00
|
|
|
#define VGA_WIDTH 80
|
|
|
|
#define VGA_HEIGHT 25
|
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
#define FLAG_ALTNT_FORM 0x01
|
|
|
|
#define FLAG_ALTNT_FORM_CH '#'
|
|
|
|
|
|
|
|
#define FLAG_ZERO_PAD 0x02
|
|
|
|
#define FLAG_ZERO_PAD_CH '0'
|
|
|
|
|
|
|
|
#define FLAG_LEFT_ADJUST 0x04
|
|
|
|
#define FLAG_LEFT_ADJUST_CH '-'
|
|
|
|
|
|
|
|
#define FLAG_SPACE_BEFORE_POS_NUM 0x08
|
|
|
|
#define FLAG_SPACE_BEFORE_POS_NUM_CH ' '
|
|
|
|
|
|
|
|
#define FLAG_SIGN 0x10
|
|
|
|
#define FLAG_SIGN_CH '+'
|
|
|
|
|
|
|
|
#define FLAG_LOWER 0x20
|
|
|
|
|
|
|
|
#define INT_TYPE_CHAR 0x1
|
|
|
|
#define INT_TYPE_SHORT 0x2
|
|
|
|
#define INT_TYPE_INT 0x4
|
|
|
|
#define INT_TYPE_LONG 0x8
|
|
|
|
#define INT_TYPE_LONG_LONG 0x10
|
|
|
|
#define INT_TYPE_MIN INT_TYPE_CHAR
|
|
|
|
#define INT_TYPE_MAX INT_TYPE_LONG_LONG
|
|
|
|
|
|
|
|
#define BUF_SIZE 4096
|
|
|
|
|
2024-05-19 18:05:00 +08:00
|
|
|
// RRRRR GGGGGG BBBBB
|
|
|
|
#define SVGA_24TO16BPP(x) ((x & 0xF80000) >> 8) | ((x & 0xFC00) >> 5) | ((x & 0xF8) >> 3)
|
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
enum vga_color {
|
2024-04-12 22:03:07 +08:00
|
|
|
VGA_COLOR_BLACK = 0,
|
|
|
|
VGA_COLOR_BLUE = 1,
|
|
|
|
VGA_COLOR_GREEN = 2,
|
|
|
|
VGA_COLOR_CYAN = 3,
|
|
|
|
VGA_COLOR_RED = 4,
|
|
|
|
VGA_COLOR_MAGENTA = 5,
|
|
|
|
VGA_COLOR_BROWN = 6,
|
|
|
|
VGA_COLOR_LIGHT_GREY = 7,
|
|
|
|
VGA_COLOR_DARK_GREY = 8,
|
|
|
|
VGA_COLOR_LIGHT_BLUE = 9,
|
|
|
|
VGA_COLOR_LIGHT_GREEN = 10,
|
|
|
|
VGA_COLOR_LIGHT_CYAN = 11,
|
|
|
|
VGA_COLOR_LIGHT_RED = 12,
|
|
|
|
VGA_COLOR_LIGHT_MAGENTA = 13,
|
|
|
|
VGA_COLOR_LIGHT_BROWN = 14,
|
|
|
|
VGA_COLOR_WHITE = 15,
|
2024-04-09 23:46:56 +08:00
|
|
|
};
|
|
|
|
|
2024-04-12 22:03:07 +08:00
|
|
|
struct color_rgba {
|
|
|
|
uint8_t r;
|
|
|
|
uint8_t g;
|
|
|
|
uint8_t b;
|
|
|
|
uint8_t a;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct color_rgba color_rgba;
|
|
|
|
|
2024-05-02 11:06:52 +08:00
|
|
|
uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg);
|
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void vga_install(void);
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void vga_setcolor(uint8_t color);
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void vga_putentryat(char c, uint8_t color, size_t x, size_t y);
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void vga_putchar(char c);
|
2024-04-12 22:03:07 +08:00
|
|
|
|
|
|
|
void vga_write(const char *data, size_t size);
|
|
|
|
|
|
|
|
void vga_writestring(const char *data);
|
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void vga_write_dec(uint32_t dec);
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-04-10 01:18:08 +08:00
|
|
|
uint16_t vga_entry(unsigned char uc, uint8_t color);
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void vga_clear();
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
void move_cursor();
|
2024-04-12 22:03:07 +08:00
|
|
|
|
2024-05-21 21:09:04 +08:00
|
|
|
void vbe_putchar(char c);
|
|
|
|
void vbe_clear();
|
|
|
|
void vbe_write(const char *data, size_t size);
|
|
|
|
void vbe_writestring(const char *data);
|
|
|
|
void vbe_scroll();
|
|
|
|
int cur_task();
|
|
|
|
void vbe_draw_char(char c,int32_t x,int32_t y);
|
|
|
|
void initVBE(multiboot_t *multiboot);
|
|
|
|
|
2024-05-19 18:05:00 +08:00
|
|
|
|
2024-04-09 23:46:56 +08:00
|
|
|
#endif
|