1 /* 2 * Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de. 3 * Copyright 2008, Stephan Aßmus <superstippi@gmx.de> 4 * Copyright 2008, Philippe Saint-Pierre <stpere@gmail.com> 5 * Distributed under the terms of the MIT License. 6 */ 7 8 9 #include "video.h" 10 #include "mmu.h" 11 12 #include <arch/cpu.h> 13 #include <boot/stage2.h> 14 #include <boot/platform.h> 15 #include <boot/menu.h> 16 #include <boot/kernel_args.h> 17 #include <boot/images.h> 18 #include <boot/platform/generic/video.h> 19 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <string.h> 23 24 25 //#define TRACE_VIDEO 26 #ifdef TRACE_VIDEO 27 # define TRACE(x) dprintf x 28 #else 29 # define TRACE(x) ; 30 #endif 31 32 33 extern "C" status_t 34 video_display_splash(addr_t frameBuffer) 35 { 36 if (!gKernelArgs.frame_buffer.enabled) 37 return B_NO_INIT; 38 39 // clear the video memory 40 memset((void *)frameBuffer, 0, 41 gKernelArgs.frame_buffer.physical_buffer.size); 42 43 uint8 *uncompressedLogo = NULL; 44 switch (gKernelArgs.frame_buffer.depth) { 45 case 8: 46 platform_set_palette(k8BitPalette); 47 uncompressedLogo = (uint8 *)kernel_args_malloc(kSplashLogoWidth 48 * kSplashLogoHeight); 49 if (uncompressedLogo == NULL) 50 return B_NO_MEMORY; 51 uncompress_8bit_RLE(kSplashLogo8BitCompressedImage, 52 uncompressedLogo); 53 break; 54 default: 55 uncompressedLogo = (uint8 *)kernel_args_malloc(kSplashLogoWidth 56 * kSplashLogoHeight * 3); 57 if (uncompressedLogo == NULL) 58 return B_NO_MEMORY; 59 uncompress_24bit_RLE(kSplashLogo24BitCompressedImage, 60 uncompressedLogo); 61 break; 62 } 63 64 // TODO: support 4-bit indexed version of the images! 65 66 // render splash logo 67 uint16 iconsHalfHeight = kSplashIconsHeight / 2; 68 69 int width = min_c(kSplashLogoWidth, gKernelArgs.frame_buffer.width); 70 int height = min_c(kSplashLogoHeight + iconsHalfHeight, 71 gKernelArgs.frame_buffer.height); 72 int placementX = max_c(0, min_c(100, kSplashLogoPlacementX)); 73 int placementY = max_c(0, min_c(100, kSplashLogoPlacementY)); 74 75 int x = (gKernelArgs.frame_buffer.width - width) * placementX / 100; 76 int y = (gKernelArgs.frame_buffer.height - height) * placementY / 100; 77 78 height = min_c(kSplashLogoHeight, gKernelArgs.frame_buffer.height); 79 switch (gKernelArgs.frame_buffer.depth) { 80 case 8: 81 break; 82 } 83 video_blit_image(frameBuffer, uncompressedLogo, width, height, 84 kSplashLogoWidth, x, y); 85 86 kernel_args_free(uncompressedLogo); 87 88 const uint8* lowerHalfIconImage; 89 90 switch (gKernelArgs.frame_buffer.depth) { 91 case 8: 92 // pointer into the lower half of the icons image data 93 gKernelArgs.boot_splash 94 = (uint8 *)kernel_args_malloc(kSplashIconsWidth 95 * kSplashIconsHeight); 96 if (gKernelArgs.boot_splash == NULL) 97 return B_NO_MEMORY; 98 uncompress_8bit_RLE(kSplashIcons8BitCompressedImage, 99 gKernelArgs.boot_splash ); 100 lowerHalfIconImage = gKernelArgs.boot_splash 101 + (kSplashIconsWidth * iconsHalfHeight); 102 break; 103 default: 104 // pointer into the lower half of the icons image data 105 gKernelArgs.boot_splash 106 = (uint8 *)kernel_args_malloc(kSplashIconsWidth 107 * kSplashIconsHeight * 3); 108 if (gKernelArgs.boot_splash == NULL) 109 return B_NO_MEMORY; 110 uncompress_24bit_RLE(kSplashIcons24BitCompressedImage, 111 gKernelArgs.boot_splash ); 112 lowerHalfIconImage = gKernelArgs.boot_splash 113 + (kSplashIconsWidth * iconsHalfHeight) * 3; 114 break; 115 } 116 117 // render initial (grayed out) icons 118 // the grayed out version is the lower half of the icons image 119 120 width = min_c(kSplashIconsWidth, gKernelArgs.frame_buffer.width); 121 height = min_c(kSplashLogoHeight + iconsHalfHeight, 122 gKernelArgs.frame_buffer.height); 123 placementX = max_c(0, min_c(100, kSplashIconsPlacementX)); 124 placementY = max_c(0, min_c(100, kSplashIconsPlacementY)); 125 126 x = (gKernelArgs.frame_buffer.width - width) * placementX / 100; 127 y = kSplashLogoHeight + (gKernelArgs.frame_buffer.height - height) 128 * placementY / 100; 129 130 height = min_c(iconsHalfHeight, gKernelArgs.frame_buffer.height); 131 video_blit_image(frameBuffer, lowerHalfIconImage, width, height, 132 kSplashIconsWidth, x, y); 133 return B_OK; 134 } 135 136