Load wallpaper from file on disk

This commit is contained in:
Kevin Lange 2011-11-18 14:38:27 -06:00
parent 7d9fa21d19
commit b2b8185494
5 changed files with 48 additions and 19 deletions

View File

@ -28,7 +28,7 @@ ERRORSS = >>/tmp/.build-errors || util/mk-error
BEGRM = util/mk-beg-rm
ENDRM = util/mk-end-rm
EMUARGS = -kernel toaruos-kernel -initrd toaruos-initrd -append "vid=qemu wallpaper" -serial stdio -vga std -hda toaruos-disk.img -hdb util/toaruos-wallpaper.bmp
EMUARGS = -kernel toaruos-kernel -initrd toaruos-initrd -append "vid=qemu wallpaper=/usr/share/wallpaper.bmp" -serial stdio -vga std -hda toaruos-disk.img
EMUKVM = -enable-kvm
.PHONY: all check-toolchain system clean clean-once clean-hard clean-soft clean-docs clean-bin clean-aux clean-core clean-boot install run docs utils

View File

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -8,6 +8,8 @@
*/
#include <system.h>
extern void bochs_install_wallpaper(char *);
/**
* Parse the given arguments to the kernel.
*
@ -38,13 +40,31 @@ parse_args(
for (int i = 0; i < tokenid; ++i) {
/* Parse each provided argument */
char * pch_i;
char * save_i;
char * argp[1024];
int argc = 0;
pch_i = strtok_r(argv[i],"=",&save_i);
if (!pch_i) { continue; }
while (pch_i != NULL) {
argp[argc] = (char *)pch_i;
++argc;
pch_i = strtok_r(NULL,"=",&save_i);
}
argp[argc] = NULL;
if (!strcmp(argv[i],"vid=qemu")) {
/* Bochs / Qemu Video Device */
graphics_install_bochs();
ansi_init(&bochs_write, 128, 64);
} if (!strcmp(argv[i],"wallpaper")) {
bochs_install_wallpaper();
if (!strcmp(argp[0],"vid")) {
if (argc < 2) { kprintf("vid=?\n"); continue; }
if (!strcmp(argp[1],"qemu")) {
/* Bochs / Qemu Video Device */
graphics_install_bochs();
ansi_init(&bochs_write, 128, 64);
} else {
kprintf("Unrecognized video adapter: %s\n", argp[1]);
}
} else if (!strcmp(argp[0],"wallpaper")) {
if (argc < 2) { kprintf("wallpaper=?\n"); continue; }
bochs_install_wallpaper(argp[1]);
}
}
}

View File

@ -96,14 +96,23 @@ bochs_screenshot() {
}
void
bochs_install_wallpaper() {
char * bufferb = malloc(2359808);
uint32_t _i = 0;
kprintf("Loading...");
while (_i < 4609) {
ide_read_sector(0x1F0, 1, _i, (uint8_t *)((uint32_t)bufferb + _i * 512));
++_i;
bochs_install_wallpaper(char * filename) {
kprintf("Loading wallpaper... ");
fs_node_t * image = kopen(filename, 0);
if (!image) {
kprintf("Could not load wallpaper (%s), bailing.\n", filename);
return;
}
size_t image_size= 0;
image_size = image->length;
/* Alright, we have the length */
char * bufferb = malloc(image_size);
read_fs(image, 0, image_size, (uint8_t *)bufferb);
close_fs(image);
uint16_t x = 0; /* -> 212 */
uint16_t y = 0; /* -> 68 */
/* Get the width / height of the image */
@ -120,8 +129,6 @@ bochs_install_wallpaper() {
wallpaper->height = height;
wallpaper->bitmap = malloc(sizeof(uint32_t) * width * height);
kprintf("Loading...");
for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) {
/* Extract the color */

View File

@ -139,15 +139,17 @@ int main(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp)
initrd_mount((uintptr_t)ramdisk, 0);
}
}
/* Parse the command-line arguments */
parse_args((char *)mboot_ptr->cmdline);
}
mouse_install(); /* Mouse driver */
extern void ext2_disk_mount(void);
ext2_disk_mount();
if (boot_mode == multiboot) {
/* Parse the command-line arguments */
parse_args((char *)mboot_ptr->cmdline);
}
cls();
start_shell();