feature: start to implement the drivers for char printing support
This commit is contained in:
parent
e5bdd1b5ee
commit
33cb3dfa30
@ -5,5 +5,5 @@
|
||||
struct font {
|
||||
uint32_t height;
|
||||
uint32_t width;
|
||||
char **bitmap;
|
||||
char *bitmap;
|
||||
};
|
1647
headers/fonts/eating_pasta_regular_32.h
Normal file
1647
headers/fonts/eating_pasta_regular_32.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "icon.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct vbe_interface {
|
||||
@ -11,3 +12,6 @@ struct vbe_interface {
|
||||
};
|
||||
|
||||
extern struct vbe_interface display;
|
||||
|
||||
void draw_icon(uint32_t pos_x, uint32_t pos_y, struct icon *img);
|
||||
void put_pixel(uint32_t color, uint32_t x, uint32_t y);
|
||||
|
@ -1,10 +1,22 @@
|
||||
#include "vbe.h"
|
||||
#include "drivers.h"
|
||||
#include "icon.h"
|
||||
|
||||
struct vbe_interface display;
|
||||
|
||||
void put_pixel(uint16_t x, uint16_t y)
|
||||
void put_pixel(uint32_t color, uint32_t x, uint32_t y)
|
||||
{
|
||||
|
||||
//
|
||||
// divide by 4 because display.buff is in 32bit instead of 8bit
|
||||
const uint32_t coords = x + y * display.pitch / 4;
|
||||
display.buff[coords] = color;
|
||||
}
|
||||
|
||||
void draw_icon(uint32_t pos_x, uint32_t pos_y, struct icon *img)
|
||||
{
|
||||
for (uint32_t y = 0; y < img->height; y++) {
|
||||
for (uint32_t x = 0; x < img->width; x++) {
|
||||
put_pixel(img->pixels[y * img->width + x], pos_x + x,
|
||||
pos_y + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
src/kernel.c
20
src/kernel.c
@ -29,24 +29,6 @@
|
||||
#error "This tutorial needs to be compiled with a ix86-elf compiler"
|
||||
#endif
|
||||
|
||||
static void put_pixel(uint32_t color, uint32_t x, uint32_t y)
|
||||
{
|
||||
// /
|
||||
// 4 cause display.buff is in 32bit instead of 8bit
|
||||
const uint32_t coords = x + y * display.pitch / 4;
|
||||
display.buff[coords] = color;
|
||||
}
|
||||
|
||||
void draw_icon(uint32_t pos_x, uint32_t pos_y, struct icon *img)
|
||||
{
|
||||
for (uint32_t y = 0; y < img->height; y++) {
|
||||
for (uint32_t x = 0; x < img->width; x++) {
|
||||
put_pixel(img->pixels[y * img->width + x], pos_x + x,
|
||||
pos_y + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
{
|
||||
/* terminal_initialize(); */
|
||||
@ -60,7 +42,7 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
/* "complex 8*unknown quantity -byte descriptor table. -- Troy "
|
||||
*/
|
||||
/* "Martin 03:50, 22 March 2009 (UTC)\n"); */
|
||||
draw_icon(0, 0, &image_icon);
|
||||
terminal_putchar('A');
|
||||
/* memset(display.buff, 255, 1024 * 1024); */
|
||||
/* shell_init(); */
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include "ctype.h"
|
||||
#include "font.h"
|
||||
#include "fonts/eating_pasta_regular_32.h"
|
||||
#include "kprintf.h"
|
||||
#include "shell.h"
|
||||
#include "string.h"
|
||||
#include "sys/io.h"
|
||||
#include "terminal.h"
|
||||
#include "vbe.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@ -82,13 +85,19 @@ uint8_t terminal_get_default_color(void)
|
||||
|
||||
uint8_t terminal_get_char(int column, int row)
|
||||
{
|
||||
/* return screen->buffer[row * VGA_WIDTH + column]; */
|
||||
return screen->buffer[row * VGA_WIDTH + column];
|
||||
}
|
||||
|
||||
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
|
||||
void terminal_putentryat(char c, uint32_t color, size_t x, size_t y)
|
||||
{
|
||||
const size_t index = y * VGA_WIDTH + x;
|
||||
TERM_BUF[index] = vga_entry(c, color);
|
||||
struct font node = eating_pasta_regular_32_font[(int)c];
|
||||
char *glyph = node.bitmap;
|
||||
for (size_t cy = 0; cy < node.height; cy++)
|
||||
for (size_t cx = 0; cx < node.width; cx++)
|
||||
if (glyph[cy + node.width + cx] == '#')
|
||||
put_pixel(color, x + cx, y + cy);
|
||||
/* const size_t index = y * VGA_WIDTH + x; */
|
||||
/* TERM_BUF[index] = vga_entry(c, color); */
|
||||
}
|
||||
|
||||
static void terminal_scroll(void)
|
||||
@ -151,16 +160,18 @@ void terminal_clear(void)
|
||||
|
||||
int terminal_putchar(char c)
|
||||
{
|
||||
if (c == '\r')
|
||||
screen->column = 0;
|
||||
else if (c == '\n')
|
||||
terminal_new_line();
|
||||
if (!isprint(c))
|
||||
return 1;
|
||||
terminal_putentryat(c, screen->color, screen->column, screen->row);
|
||||
if (++screen->column == VGA_WIDTH)
|
||||
terminal_new_line();
|
||||
return 1;
|
||||
terminal_putentryat(c, 0xCCFFE5, 10, 10);
|
||||
/* if (c == '\r') */
|
||||
/* screen->column = 0; */
|
||||
/* else if (c == '\n') */
|
||||
/* terminal_new_line(); */
|
||||
/* if (!isprint(c)) */
|
||||
/* return 1; */
|
||||
/* terminal_putentryat(c, screen->color, screen->column, screen->row);
|
||||
*/
|
||||
/* if (++screen->column == VGA_WIDTH) */
|
||||
/* terminal_new_line(); */
|
||||
/* return 1; */
|
||||
}
|
||||
|
||||
int terminal_write(const char *data, size_t size)
|
||||
|
Loading…
Reference in New Issue
Block a user