add: image is now printable
This commit is contained in:
26
src/kernel.c
26
src/kernel.c
@ -2,6 +2,8 @@
|
||||
#include "debug.h"
|
||||
#include "drivers.h"
|
||||
#include "gdt.h"
|
||||
#include "icon.h"
|
||||
#include "icons/image.h"
|
||||
#include "idt.h"
|
||||
#include "kprintf.h"
|
||||
#include "memory.h"
|
||||
@ -29,11 +31,22 @@
|
||||
|
||||
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;
|
||||
// /
|
||||
// 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(); */
|
||||
@ -47,14 +60,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"); */
|
||||
uint32_t color = 0 << 16 | 128 << 8 | 128;
|
||||
for (size_t i = 0; i < 100; i++) {
|
||||
put_pixel(color, 10, i);
|
||||
put_pixel(color, 11, i);
|
||||
put_pixel(color, 12, i);
|
||||
put_pixel(color, 13, i);
|
||||
put_pixel(color, 14, i);
|
||||
}
|
||||
draw_icon(0, 0, &image_icon);
|
||||
/* memset(display.buff, 255, 1024 * 1024); */
|
||||
/* shell_init(); */
|
||||
}
|
||||
|
Reference in New Issue
Block a user