diff options
author | Marvin Borner | 2020-08-27 22:31:44 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-27 22:31:44 +0200 |
commit | 834ab9e2771b631c46d34fa906b4e2448f9192ca (patch) | |
tree | 828d7aed8a6a885f8100bc61b9453f003f45cb04 | |
parent | 5565c4f1d12d9bdbabcc878541d3b81be45d4cf3 (diff) |
Kinda fixed wallpapers
-rw-r--r-- | apps/wm.c | 5 | ||||
-rw-r--r-- | kernel/features/fs.c | 2 | ||||
-rw-r--r-- | kernel/inc/ide.h | 1 | ||||
-rw-r--r-- | libgui/gui.c | 21 | ||||
-rw-r--r-- | res/wall.bmp | bin | 0 -> 9216138 bytes |
5 files changed, 23 insertions, 6 deletions
@@ -66,8 +66,7 @@ int main(int argc, char **argv) gui_fill(root, BG_COLOR); gui_border(root, FG_COLOR, 2); gui_load_image(cursor, "/res/cursor.bmp", 0, 0); - // TODO: Fix wallpaper - /* gui_load_wallpaper(root, "/wall.bmp"); */ + gui_load_wallpaper(root, "/res/wall.bmp"); redraw_all(); event_register(EVENT_KEYBOARD); @@ -84,7 +83,7 @@ int main(int argc, char **argv) case MSG_NEW_WINDOW: printf("New window for pid %d\n", msg->src); struct window *win = - new_window(vbe->width / 2 - 100, vbe->height / 2 - 100, 500, 300); + new_window(vbe->width / 2 - 250, vbe->height / 2 - 150, 500, 300); msg_send(msg->src, MSG_NEW_WINDOW, win); list_add(windows, win); focused = win; diff --git a/kernel/features/fs.c b/kernel/features/fs.c index 52d1bb0..a0c8735 100644 --- a/kernel/features/fs.c +++ b/kernel/features/fs.c @@ -72,7 +72,7 @@ void *read_inode(struct inode *in) int blocknum; char *data; - // TODO: Support treply indirect pointers + // TODO: Support triply indirect pointers // TODO: This can be heavily optimized by saving the indirect block lists for (int i = 0; i < num_blocks; i++) { if (i < 12) { diff --git a/kernel/inc/ide.h b/kernel/inc/ide.h index 9d753ae..e88a6d7 100644 --- a/kernel/inc/ide.h +++ b/kernel/inc/ide.h @@ -6,6 +6,7 @@ #include <def.h> #define BLOCK_SIZE 1024 +#define BLOCK_COUNT 256 // BLOCK_SIZE / sizeof(u32) #define SECTOR_SIZE 512 #define IDE_BUSY (1 << 7) diff --git a/libgui/gui.c b/libgui/gui.c index 9c35505..3279ab0 100644 --- a/libgui/gui.c +++ b/libgui/gui.c @@ -67,13 +67,14 @@ void gui_write(struct window *win, int x, int y, u32 c, char *text) void gui_load_image(struct window *win, char *path, int x, int y) { + // TODO: Support x, y struct bmp *bmp = bmp_load(path); assert(bmp && bmp->width + x <= win->width); assert(bmp && bmp->height + y <= win->height); // TODO: Support padding with odd widths int bypp = bmp->bpp >> 3; - u8 *srcfb = &bmp->data[bypp + bmp->width * bmp->pitch]; + u8 *srcfb = &bmp->data[bypp + bmp->height * bmp->pitch]; u8 *destfb = &win->fb[bypp]; for (u32 cy = 0; cy < bmp->height; cy++) { memcpy(destfb, srcfb, bmp->pitch); @@ -85,7 +86,23 @@ void gui_load_image(struct window *win, char *path, int x, int y) void gui_load_wallpaper(struct window *win, char *path) { - gui_load_image(win, path, 0, 0); + struct bmp *bmp = bmp_load(path); + assert(bmp && bmp->width <= win->width); + assert(bmp && bmp->height <= win->height); + + // TODO: Support padding with odd widths + int bypp = bmp->bpp >> 3; + // TODO: Find out why bigger images need some kind of offset + int magic_offset = bmp->pitch + 1024; + u8 *srcfb = &bmp->data[bypp + bmp->height * bmp->pitch - magic_offset]; + u8 *destfb = &win->fb[bypp]; + for (u32 cy = 0; cy < bmp->height; cy++) { + memcpy(destfb, srcfb, bmp->pitch); + srcfb -= bmp->pitch; + destfb += win->pitch; + } + gui_redraw(); + /* gui_load_image(win, path, 0, 0); */ } void gui_copy(struct window *dest, struct window *src, int x, int y, u32 width, u32 height) diff --git a/res/wall.bmp b/res/wall.bmp Binary files differnew file mode 100644 index 0000000..0188866 --- /dev/null +++ b/res/wall.bmp |