- /* Get information about our graphics mode, like the
- * framebuffer start address
- */
- memset(&br, 0, sizeof(br));
- br.ax = 0x4f01;
- br.cx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE;
- br.di = FLATPTR_TO_OFFSET(mode_info);
- br.es = FLATPTR_TO_SEG(mode_info);
- call16_int10(&br);
- if (br.ax != 0x4f) {
- dprintf(1, "get_mode failed.\n");
+ // Parse jpeg and get image size.
+ cbfs_copyfile(file, filedata, filesize);
+ int ret = jpeg_decode(jpeg, filedata);
+ if (ret) {
+ dprintf(1, "jpeg_decode failed with return code %d...\n", ret);
+ goto gotext;
+ }
+ int width, height;
+ jpeg_get_size(jpeg, &width, &height);
+
+ // Try to find a graphics mode with the corresponding dimensions.
+ int videomode = find_videomode(vesa_info, mode_info, width, height);
+ if (videomode < 0)
+ goto gotext;
+ void *framebuffer = mode_info->phys_base_ptr;
+ int depth = mode_info->bits_per_pixel;
+ dprintf(3, "mode: %04x\n", videomode);
+ dprintf(3, "framebuffer: %p\n", framebuffer);
+ dprintf(3, "bytes per scanline: %d\n", mode_info->bytes_per_scanline);
+ dprintf(3, "bits per pixel: %d\n", depth);
+
+ // Allocate space for image and decompress it.
+ int imagesize = width * height * (depth / 8);
+ picture = malloc_tmphigh(imagesize);
+ if (!picture) {
+ warn_noalloc();
+ goto gotext;
+ }
+ ret = jpeg_show(jpeg, picture, width, height, depth);
+ if (ret) {
+ dprintf(1, "jpeg_show failed with return code %d...\n", ret);