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 {
|
struct font {
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
uint32_t width;
|
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
|
#pragma once
|
||||||
|
|
||||||
|
#include "icon.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct vbe_interface {
|
struct vbe_interface {
|
||||||
@ -11,3 +12,6 @@ struct vbe_interface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern struct vbe_interface display;
|
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 "vbe.h"
|
||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
|
#include "icon.h"
|
||||||
|
|
||||||
struct vbe_interface display;
|
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"
|
#error "This tutorial needs to be compiled with a ix86-elf compiler"
|
||||||
#endif
|
#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)
|
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||||
{
|
{
|
||||||
/* terminal_initialize(); */
|
/* terminal_initialize(); */
|
||||||
@ -60,7 +42,7 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
|||||||
/* "complex 8*unknown quantity -byte descriptor table. -- Troy "
|
/* "complex 8*unknown quantity -byte descriptor table. -- Troy "
|
||||||
*/
|
*/
|
||||||
/* "Martin 03:50, 22 March 2009 (UTC)\n"); */
|
/* "Martin 03:50, 22 March 2009 (UTC)\n"); */
|
||||||
draw_icon(0, 0, &image_icon);
|
terminal_putchar('A');
|
||||||
/* memset(display.buff, 255, 1024 * 1024); */
|
/* memset(display.buff, 255, 1024 * 1024); */
|
||||||
/* shell_init(); */
|
/* shell_init(); */
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#include "ctype.h"
|
#include "ctype.h"
|
||||||
|
#include "font.h"
|
||||||
|
#include "fonts/eating_pasta_regular_32.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "sys/io.h"
|
#include "sys/io.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "vbe.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -82,13 +85,19 @@ uint8_t terminal_get_default_color(void)
|
|||||||
|
|
||||||
uint8_t terminal_get_char(int column, int row)
|
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;
|
struct font node = eating_pasta_regular_32_font[(int)c];
|
||||||
TERM_BUF[index] = vga_entry(c, color);
|
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)
|
static void terminal_scroll(void)
|
||||||
@ -151,16 +160,18 @@ void terminal_clear(void)
|
|||||||
|
|
||||||
int terminal_putchar(char c)
|
int terminal_putchar(char c)
|
||||||
{
|
{
|
||||||
if (c == '\r')
|
terminal_putentryat(c, 0xCCFFE5, 10, 10);
|
||||||
screen->column = 0;
|
/* if (c == '\r') */
|
||||||
else if (c == '\n')
|
/* screen->column = 0; */
|
||||||
terminal_new_line();
|
/* else if (c == '\n') */
|
||||||
if (!isprint(c))
|
/* terminal_new_line(); */
|
||||||
return 1;
|
/* if (!isprint(c)) */
|
||||||
terminal_putentryat(c, screen->color, screen->column, screen->row);
|
/* return 1; */
|
||||||
if (++screen->column == VGA_WIDTH)
|
/* terminal_putentryat(c, screen->color, screen->column, screen->row);
|
||||||
terminal_new_line();
|
*/
|
||||||
return 1;
|
/* if (++screen->column == VGA_WIDTH) */
|
||||||
|
/* terminal_new_line(); */
|
||||||
|
/* return 1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
int terminal_write(const char *data, size_t size)
|
int terminal_write(const char *data, size_t size)
|
||||||
|
Loading…
Reference in New Issue
Block a user