vbe: Ensure that the format is xRGB8888 for the graphical menu
diff --git a/limine-pxe.bin b/limine-pxe.bin
index daccaffa..32deb39f 100644
Binary files a/limine-pxe.bin and b/limine-pxe.bin differ
diff --git a/limine.bin b/limine.bin
index 41cb7f2c..0a799537 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/drivers/vbe.c b/stage2/drivers/vbe.c
index 1ffd2cb6..fd7bf411 100644
--- a/stage2/drivers/vbe.c
+++ b/stage2/drivers/vbe.c
@@ -316,9 +316,18 @@ void vbe_putchar(char c) {
}
}
-void vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _margin_gradient, struct image *_background) {
+bool vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _margin_gradient, struct image *_background) {
init_vbe(&fbinfo, 0, 0, 0);
+ // Ensure this is xRGB8888, we only support that for the menu
+ if (fbinfo.red_mask_size != 8
+ || fbinfo.red_mask_shift != 16
+ || fbinfo.green_mask_size != 8
+ || fbinfo.green_mask_shift != 8
+ || fbinfo.blue_mask_size != 8
+ || fbinfo.blue_mask_shift != 0)
+ return false;
+
vbe_framebuffer = (void *)fbinfo.framebuffer_addr;
vbe_width = fbinfo.framebuffer_width;
vbe_height = fbinfo.framebuffer_height;
@@ -348,6 +357,8 @@ void vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _
vbe_plot_background(0, 0, vbe_width, vbe_height);
vbe_clear(true);
+
+ return true;
}
struct vbe_info_struct {
diff --git a/stage2/drivers/vbe.h b/stage2/drivers/vbe.h
index ead7f284..48e6f9fd 100644
--- a/stage2/drivers/vbe.h
+++ b/stage2/drivers/vbe.h
@@ -23,7 +23,7 @@ struct vbe_framebuffer_info {
bool init_vbe(struct vbe_framebuffer_info *ret,
uint16_t target_width, uint16_t target_height, uint16_t target_bpp);
-void vbe_tty_init(int *rows, int *cols, uint32_t *colours, int margin, int margin_gradient, struct image *background);
+bool vbe_tty_init(int *rows, int *cols, uint32_t *colours, int margin, int margin_gradient, struct image *background);
void vbe_putchar(char c);
void vbe_clear(bool move);
diff --git a/stage2/lib/bmp.c b/stage2/lib/bmp.c
index 5f101c9a..5c7a1265 100644
--- a/stage2/lib/bmp.c
+++ b/stage2/lib/bmp.c
@@ -43,6 +43,7 @@ static uint32_t get_pixel(struct image *this, int x, int y) {
size_t pixel_offset = local->pitch * (header->bi_height - y - 1) + x * (header->bi_bpp / 8);
+ // TODO: Perhaps use masks here, they're there for a reason
uint32_t composite = 0;
for (int i = 0; i < header->bi_bpp / 8; i++)
composite |= (uint32_t)local->image[pixel_offset + i] << (i * 8);
diff --git a/stage2/lib/term.c b/stage2/lib/term.c
index 17f2f8bf..64c8972a 100644
--- a/stage2/lib/term.c
+++ b/stage2/lib/term.c
@@ -26,7 +26,11 @@ int term_rows, term_cols;
void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background) {
term_deinit();
- vbe_tty_init(&term_rows, &term_cols, colours, margin, margin_gradient, background);
+ if (!vbe_tty_init(&term_rows, &term_cols, colours, margin, margin_gradient, background)) {
+ // Failed to set VBE properly, default to text mode
+ term_textmode();
+ return;
+ }
raw_putchar = vbe_putchar;
clear = vbe_clear;
