Skip to content

Instantly share code, notes, and snippets.

@Azure-Agst
Last active May 16, 2018 12:26
Show Gist options
  • Save Azure-Agst/29f2d347197b30351b24c4e6321bdefd to your computer and use it in GitHub Desktop.
Save Azure-Agst/29f2d347197b30351b24c4e6321bdefd to your computer and use it in GitHub Desktop.
uh
#include "utils.h"
#include "timers.h"
#include "splash_screen.h"
#include "sd_utils.h"
#include "lib/printk.h"
#include "display/video_fb.h"
#include "console.h"
struct BMP {
char Type[2]; //File type. Set to "BM".
unsigned long Size; //Size in BYTES of the file.
unsigned long Reserved; //Reserved. Set to zero.
unsigned long OffSet; //Offset to the data.
unsigned long headsize; //Size of rest of header. Set to 40.
unsigned long Width; //Width of bitmap in pixels.
unsigned long Height; // Height of bitmap in pixels.
unsigned int Planes; //Number of Planes. Set to 1.
unsigned int BitsPerPixel; //Number of Bits per pixels.
unsigned long Compression; //Compression. Usually set to 0.
unsigned long SizeImage; //Size in bytes of the bitmap.
unsigned long XPixelsPreMeter; //Horizontal pixels per meter.
unsigned long YPixelsPreMeter; //Vertical pixels per meter.
unsigned long ColorsUsed; //Number of colors used.
unsigned long ColorsImportant; //Number of "important" colors.
};
void display_splash_screen_bmp(const char *custom_splash_path) {
unsigned char *splash_screen = g_default_splash_screen;
if (custom_splash_path != NULL && custom_splash_path[0] != '\x00') {
if (!read_sd_file(splash_screen, sizeof(g_default_splash_screen), custom_splash_path)) {
printk("Error: Failed to read custom splash screen from %s!\n", custom_splash_path);
generic_panic();
}
}
BMP splash;
memcpy(*splash, splash_screen, sizeof(splash));
if (!splash.Type[0] == "B" || !splash.Type[1] == "M") {
printk("Error: Not a real BMP!");
generic_panic();
}
u32 imagedata = &splashscreen + &splash.Offset;
u32* framebuf = *console_get_framebuffer();
// framebuffer is in RGBA
// bmp is in BRGA
u32 x, y;
for (y=0;y<720;y++){
for (x=0;x<1280;x++){
pos = (1280 * 720) - (y * 720) + x;
framebuf[pos+2] = imageptr[pos*4+0]; //red
framebuf[pos+1] = imageptr[pos*4+1]; //green
framebuf[pos] = imageptr[pos*4+2]; //blue
framebuf[pos+3] = imageptr[pos*4+3]; //alpha
}
}
/* Display the splash screen for three seconds. */
wait(3000000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment