gterm: Many improvements
This commit is contained in:
parent
e402508b61
commit
7ac20e0615
|
@ -54,9 +54,12 @@ Some keys take *URIs* as values; these are described in the next section.
|
||||||
* `GRAPHICS` - If set to `yes`, use a graphical framebuffer for the boot menu, else use text mode. Ignored with Limine UEFI, forced to `yes`.
|
* `GRAPHICS` - If set to `yes`, use a graphical framebuffer for the boot menu, else use text mode. Ignored with Limine UEFI, forced to `yes`.
|
||||||
* `MENU_RESOLUTION` - Specify screen resolution to be used by the Limine menu in the form `<width>x<height>`. This will *only* affect the menu, not any booted OS. If not specified, Limine will pick a resolution automatically. If the resolution is not available, Limine will pick another one automatically. Ignored if `GRAPHICS` is not `yes`.
|
* `MENU_RESOLUTION` - Specify screen resolution to be used by the Limine menu in the form `<width>x<height>`. This will *only* affect the menu, not any booted OS. If not specified, Limine will pick a resolution automatically. If the resolution is not available, Limine will pick another one automatically. Ignored if `GRAPHICS` is not `yes`.
|
||||||
* `MENU_BRANDING` - A string that will be displayed on top of the Limine menu.
|
* `MENU_BRANDING` - A string that will be displayed on top of the Limine menu.
|
||||||
* `MENU_FONT` - URI path to a font file to be used instead of the default one for the menu. The font file must be a code page 437 character set comprised of 256 consecutive 8x16 glyphs bitmaps (4096 byte font file). Each glyph's bitmap must be expressed left to right (1 byte per row), and top to bottom (16 bytes per whole glyph).
|
* `MENU_FONT` - URI path to a font file to be used instead of the default one for the menu and terminal. The font file must be a code page 437 character set comprised of 256 consecutive 8x16 glyphs bitmaps (4096 byte font file). Each glyph's bitmap must be expressed left to right (1 byte per row), and top to bottom (16 bytes per whole glyph).
|
||||||
|
* `TERMINAL_FONT` - Alias of `MENU_FONT`.
|
||||||
* `THEME_COLOURS` - Specifies the colour palette used by the terminal (AARRGGBB). It is a `;` separated array of 10 colours: black, red, green, brown, blue, magenta, cyan, gray, background, and foreground respectively. While an alpha transparency value can be specified for every colour, it is ignored for all but background. Ignored if `GRAPHICS` is not `yes`.
|
* `THEME_COLOURS` - Specifies the colour palette used by the terminal (AARRGGBB). It is a `;` separated array of 10 colours: black, red, green, brown, blue, magenta, cyan, gray, background, and foreground respectively. While an alpha transparency value can be specified for every colour, it is ignored for all but background. Ignored if `GRAPHICS` is not `yes`.
|
||||||
* `THEME_COLORS` - Alias of `THEME_COLOURS`.
|
* `THEME_COLORS` - Alias of `THEME_COLOURS`.
|
||||||
|
* `THEME_BACKGROUND` - Alias of the background value in `THEME_COLOURS`.
|
||||||
|
* `THEME_FOREGROUND` - Alias of the foreground value in `THEME_COLOURS`.
|
||||||
* `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`.
|
* `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`.
|
||||||
* `THEME_MARGIN_GRADIENT` - Set the thickness in pixel for the gradient around the terminal. Ignored if `GRAPHICS` is not `yes`.
|
* `THEME_MARGIN_GRADIENT` - Set the thickness in pixel for the gradient around the terminal. Ignored if `GRAPHICS` is not `yes`.
|
||||||
* `BACKGROUND_PATH` - URI where to find the background .BMP file. Ignored if `GRAPHICS` is not `yes`.
|
* `BACKGROUND_PATH` - URI where to find the background .BMP file. Ignored if `GRAPHICS` is not `yes`.
|
||||||
|
|
|
@ -130,6 +130,8 @@ static size_t preset_mode = INVALID_PRESET_MODE;
|
||||||
|
|
||||||
bool init_gop(struct fb_info *ret,
|
bool init_gop(struct fb_info *ret,
|
||||||
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
|
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
|
||||||
|
ret->default_res = false;
|
||||||
|
|
||||||
EFI_STATUS status;
|
EFI_STATUS status;
|
||||||
|
|
||||||
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||||
|
@ -167,6 +169,8 @@ bool init_gop(struct fb_info *ret,
|
||||||
size_t current_fallback = 0;
|
size_t current_fallback = 0;
|
||||||
|
|
||||||
if (!target_width || !target_height || !target_bpp) {
|
if (!target_width || !target_height || !target_bpp) {
|
||||||
|
ret->default_res = true;
|
||||||
|
|
||||||
struct edid_info_struct *edid_info = get_edid_info();
|
struct edid_info_struct *edid_info = get_edid_info();
|
||||||
if (edid_info != NULL) {
|
if (edid_info != NULL) {
|
||||||
int edid_width = (int)edid_info->det_timing_desc1[2];
|
int edid_width = (int)edid_info->det_timing_desc1[2];
|
||||||
|
@ -195,6 +199,8 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback:
|
fallback:
|
||||||
|
ret->default_res = true;
|
||||||
|
|
||||||
if (current_fallback == 0) {
|
if (current_fallback == 0) {
|
||||||
if (try_mode(ret, preset_mode, 0, 0, 0))
|
if (try_mode(ret, preset_mode, 0, 0, 0))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -120,6 +120,8 @@ bool init_vbe(struct fb_info *ret,
|
||||||
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
|
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
|
||||||
print("vbe: Initialising...\n");
|
print("vbe: Initialising...\n");
|
||||||
|
|
||||||
|
ret->default_res = false;
|
||||||
|
|
||||||
size_t current_fallback = 0;
|
size_t current_fallback = 0;
|
||||||
|
|
||||||
struct vbe_info_struct vbe_info;
|
struct vbe_info_struct vbe_info;
|
||||||
|
@ -141,6 +143,8 @@ bool init_vbe(struct fb_info *ret,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!target_width || !target_height || !target_bpp) {
|
if (!target_width || !target_height || !target_bpp) {
|
||||||
|
ret->default_res = true;
|
||||||
|
|
||||||
struct edid_info_struct *edid_info = get_edid_info();
|
struct edid_info_struct *edid_info = get_edid_info();
|
||||||
if (edid_info != NULL) {
|
if (edid_info != NULL) {
|
||||||
int edid_width = (int)edid_info->det_timing_desc1[2];
|
int edid_width = (int)edid_info->det_timing_desc1[2];
|
||||||
|
@ -216,6 +220,8 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback:
|
fallback:
|
||||||
|
ret->default_res = true;
|
||||||
|
|
||||||
if (current_fallback < SIZEOF_ARRAY(fallback_resolutions)) {
|
if (current_fallback < SIZEOF_ARRAY(fallback_resolutions)) {
|
||||||
target_width = fallback_resolutions[current_fallback].width;
|
target_width = fallback_resolutions[current_fallback].width;
|
||||||
target_height = fallback_resolutions[current_fallback].height;
|
target_height = fallback_resolutions[current_fallback].height;
|
||||||
|
|
|
@ -31,20 +31,8 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
|
||||||
init_memmap();
|
init_memmap();
|
||||||
|
|
||||||
uint32_t colourscheme[] = {
|
term_vbe(0, 0);
|
||||||
0x00000000, // black
|
early_term = true;
|
||||||
0x00aa0000, // red
|
|
||||||
0x0000aa00, // green
|
|
||||||
0x00aa5500, // brown
|
|
||||||
0x000000aa, // blue
|
|
||||||
0x00aa00aa, // magenta
|
|
||||||
0x0000aaaa, // cyan
|
|
||||||
0x00aaaaaa, // grey
|
|
||||||
0x00000000, // background (black)
|
|
||||||
0x00aaaaaa // foreground (white)
|
|
||||||
};
|
|
||||||
|
|
||||||
term_vbe(colourscheme, 64, 0, NULL);
|
|
||||||
|
|
||||||
print("Limine " LIMINE_VERSION "\n\n");
|
print("Limine " LIMINE_VERSION "\n\n");
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ cont:
|
||||||
}
|
}
|
||||||
|
|
||||||
char *config_get_value(const char *config, size_t index, const char *key) {
|
char *config_get_value(const char *config, size_t index, const char *key) {
|
||||||
if (!key)
|
if (!key || !config_ready)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
|
|
|
@ -10,6 +10,7 @@ struct resolution {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fb_info {
|
struct fb_info {
|
||||||
|
bool default_res;
|
||||||
uint8_t memory_model;
|
uint8_t memory_model;
|
||||||
uint64_t framebuffer_addr;
|
uint64_t framebuffer_addr;
|
||||||
uint16_t framebuffer_pitch;
|
uint16_t framebuffer_pitch;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <lib/gterm.h>
|
#include <lib/gterm.h>
|
||||||
|
#include <lib/term.h>
|
||||||
#include <lib/blib.h>
|
#include <lib/blib.h>
|
||||||
#include <lib/libc.h>
|
#include <lib/libc.h>
|
||||||
#include <lib/config.h>
|
#include <lib/config.h>
|
||||||
|
@ -365,17 +366,116 @@ void gterm_putchar(uint8_t c) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gterm_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _margin_gradient, struct image *_background) {
|
bool gterm_init(int *_rows, int *_cols, int width, int height) {
|
||||||
int req_width = 0, req_height = 0, req_bpp = 0;
|
if (current_video_mode >= 0
|
||||||
|
&& fbinfo.default_res == true
|
||||||
|
&& width == 0
|
||||||
|
&& height == 0
|
||||||
|
&& fbinfo.framebuffer_bpp == 32
|
||||||
|
&& !early_term) {
|
||||||
|
*_rows = rows;
|
||||||
|
*_cols = cols;
|
||||||
|
gterm_clear(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
char *menu_resolution = config_get_value(NULL, 0, "MENU_RESOLUTION");
|
if (current_video_mode >= 0
|
||||||
if (menu_resolution != NULL)
|
&& fbinfo.framebuffer_width == width
|
||||||
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
|
&& fbinfo.framebuffer_height == height
|
||||||
|
&& fbinfo.framebuffer_bpp == 32
|
||||||
|
&& !early_term) {
|
||||||
|
*_rows = rows;
|
||||||
|
*_cols = cols;
|
||||||
|
gterm_clear(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
early_term = false;
|
||||||
|
|
||||||
// We force bpp to 32
|
// We force bpp to 32
|
||||||
req_bpp = 32;
|
if (!fb_init(&fbinfo, width, height, 32))
|
||||||
|
return false;
|
||||||
|
|
||||||
fb_init(&fbinfo, req_width, req_height, req_bpp);
|
// default scheme
|
||||||
|
int margin = 64;
|
||||||
|
margin_gradient = 20;
|
||||||
|
|
||||||
|
ansi_colours[0] = 0x00000000; // black
|
||||||
|
ansi_colours[1] = 0x00aa0000; // red
|
||||||
|
ansi_colours[2] = 0x0000aa00; // green
|
||||||
|
ansi_colours[3] = 0x00aa5500; // brown
|
||||||
|
ansi_colours[4] = 0x000000aa; // blue
|
||||||
|
ansi_colours[5] = 0x00aa00aa; // magenta
|
||||||
|
ansi_colours[6] = 0x0000aaaa; // cyan
|
||||||
|
ansi_colours[7] = 0x00aaaaaa; // grey
|
||||||
|
ansi_colours[8] = 0x00000000; // background (black)
|
||||||
|
ansi_colours[9] = 0x00aaaaaa; // foreground (grey)
|
||||||
|
|
||||||
|
char *colours = config_get_value(NULL, 0, "THEME_COLOURS");
|
||||||
|
if (colours == NULL)
|
||||||
|
colours = config_get_value(NULL, 0, "THEME_COLORS");
|
||||||
|
if (colours != NULL) {
|
||||||
|
const char *first = colours;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
const char *last;
|
||||||
|
uint32_t col = strtoui(first, &last, 16);
|
||||||
|
if (first == last)
|
||||||
|
break;
|
||||||
|
ansi_colours[i] = col;
|
||||||
|
if (*last == 0)
|
||||||
|
break;
|
||||||
|
first = last + 1;
|
||||||
|
}
|
||||||
|
if (i < 8) {
|
||||||
|
ansi_colours[8] = ansi_colours[0];
|
||||||
|
ansi_colours[9] = ansi_colours[7];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *theme_background = config_get_value(NULL, 0, "THEME_BACKGROUND");
|
||||||
|
if (theme_background != NULL) {
|
||||||
|
ansi_colours[8] = strtoui(theme_background, NULL, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *theme_foreground = config_get_value(NULL, 0, "THEME_FOREGROUND");
|
||||||
|
if (theme_foreground != NULL) {
|
||||||
|
ansi_colours[9] = strtoui(theme_foreground, NULL, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *theme_margin = config_get_value(NULL, 0, "THEME_MARGIN");
|
||||||
|
if (theme_margin != NULL) {
|
||||||
|
margin = strtoui(theme_margin, NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *theme_margin_gradient = config_get_value(NULL, 0, "THEME_MARGIN_GRADIENT");
|
||||||
|
if (theme_margin_gradient != NULL) {
|
||||||
|
margin_gradient = strtoui(theme_margin_gradient, NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *background_path = config_get_value(NULL, 0, "BACKGROUND_PATH");
|
||||||
|
if (background_path != NULL) {
|
||||||
|
struct file_handle *bg_file = ext_mem_alloc(sizeof(struct file_handle));
|
||||||
|
if (uri_open(bg_file, background_path)) {
|
||||||
|
background = ext_mem_alloc(sizeof(struct image));
|
||||||
|
if (open_image(background, bg_file)) {
|
||||||
|
background = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (background != NULL) {
|
||||||
|
char *background_layout = config_get_value(NULL, 0, "BACKGROUND_STYLE");
|
||||||
|
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
|
||||||
|
char *background_colour = config_get_value(NULL, 0, "BACKDROP_COLOUR");
|
||||||
|
if (background_colour == NULL)
|
||||||
|
background_colour = config_get_value(NULL, 0, "BACKDROP_COLOR");
|
||||||
|
if (background_colour == NULL)
|
||||||
|
background_colour = "0";
|
||||||
|
uint32_t bg_col = strtoui(background_colour, NULL, 16);
|
||||||
|
image_make_centered(background, fbinfo.framebuffer_width, fbinfo.framebuffer_height, bg_col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure this is xRGB8888, we only support that for the menu
|
// Ensure this is xRGB8888, we only support that for the menu
|
||||||
if (fbinfo.red_mask_size != 8
|
if (fbinfo.red_mask_size != 8
|
||||||
|
@ -398,6 +498,8 @@ bool gterm_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _ma
|
||||||
memcpy(vga_font, (void *)_binary_font_bin_start, VGA_FONT_MAX);
|
memcpy(vga_font, (void *)_binary_font_bin_start, VGA_FONT_MAX);
|
||||||
|
|
||||||
char *menu_font = config_get_value(NULL, 0, "MENU_FONT");
|
char *menu_font = config_get_value(NULL, 0, "MENU_FONT");
|
||||||
|
if (menu_font == NULL)
|
||||||
|
menu_font = config_get_value(NULL, 0, "TERMINAL_FONT");
|
||||||
if (menu_font != NULL) {
|
if (menu_font != NULL) {
|
||||||
struct file_handle f;
|
struct file_handle f;
|
||||||
if (!uri_open(&f, menu_font)) {
|
if (!uri_open(&f, menu_font)) {
|
||||||
|
@ -407,8 +509,8 @@ bool gterm_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _ma
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*_cols = cols = (gterm_width - _margin * 2) / VGA_FONT_WIDTH;
|
*_cols = cols = (gterm_width - margin * 2) / VGA_FONT_WIDTH;
|
||||||
*_rows = rows = (gterm_height - _margin * 2) / VGA_FONT_HEIGHT;
|
*_rows = rows = (gterm_height - margin * 2) / VGA_FONT_HEIGHT;
|
||||||
|
|
||||||
size_t new_grid_size = rows * cols * sizeof(struct gterm_char);
|
size_t new_grid_size = rows * cols * sizeof(struct gterm_char);
|
||||||
if (new_grid_size > last_grid_size) {
|
if (new_grid_size > last_grid_size) {
|
||||||
|
@ -422,12 +524,6 @@ bool gterm_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _ma
|
||||||
last_front_grid_size = new_front_grid_size;
|
last_front_grid_size = new_front_grid_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
background = _background;
|
|
||||||
|
|
||||||
memcpy(ansi_colours, _colours, sizeof(ansi_colours));
|
|
||||||
|
|
||||||
margin_gradient = _margin_gradient;
|
|
||||||
|
|
||||||
frame_height = gterm_height / 2 - (VGA_FONT_HEIGHT * rows) / 2;
|
frame_height = gterm_height / 2 - (VGA_FONT_HEIGHT * rows) / 2;
|
||||||
frame_width = gterm_width / 2 - (VGA_FONT_WIDTH * cols) / 2;
|
frame_width = gterm_width / 2 - (VGA_FONT_WIDTH * cols) / 2;
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
extern struct fb_info fbinfo;
|
extern struct fb_info fbinfo;
|
||||||
|
|
||||||
bool gterm_init(int *rows, int *cols, uint32_t *colours, int margin,
|
bool gterm_init(int *_rows, int *_cols, int width, int height);
|
||||||
int margin_gradient, struct image *background);
|
|
||||||
|
|
||||||
void gterm_putchar(uint8_t c);
|
void gterm_putchar(uint8_t c);
|
||||||
void gterm_clear(bool move);
|
void gterm_clear(bool move);
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
#include <lib/blib.h>
|
#include <lib/blib.h>
|
||||||
#include <lib/gterm.h>
|
#include <lib/gterm.h>
|
||||||
|
|
||||||
void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background) {
|
bool early_term = false;
|
||||||
|
|
||||||
|
void term_vbe(int width, int height) {
|
||||||
term_backend = NOT_READY;
|
term_backend = NOT_READY;
|
||||||
|
|
||||||
if (!gterm_init(&term_rows, &term_cols, colours, margin, margin_gradient, background)) {
|
if (!gterm_init(&term_rows, &term_cols, width, height)) {
|
||||||
#if defined (bios)
|
#if defined (bios)
|
||||||
// Failed to set VBE properly, default to text mode
|
// Failed to set VBE properly, default to text mode
|
||||||
term_textmode();
|
term_textmode();
|
||||||
|
|
|
@ -17,7 +17,7 @@ extern void (*set_text_bg)(int bg);
|
||||||
extern void (*term_double_buffer)(bool status);
|
extern void (*term_double_buffer)(bool status);
|
||||||
extern void (*term_double_buffer_flush)(void);
|
extern void (*term_double_buffer_flush)(void);
|
||||||
|
|
||||||
void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background);
|
void term_vbe(int width, int height);
|
||||||
void term_textmode(void);
|
void term_textmode(void);
|
||||||
void term_write(const char *buf, size_t count);
|
void term_write(const char *buf, size_t count);
|
||||||
|
|
||||||
|
@ -34,4 +34,6 @@ enum {
|
||||||
extern int term_backend;
|
extern int term_backend;
|
||||||
extern int current_video_mode;
|
extern int current_video_mode;
|
||||||
|
|
||||||
|
extern bool early_term;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -369,85 +369,13 @@ char *menu(char **cmdline) {
|
||||||
char *graphics = "yes";
|
char *graphics = "yes";
|
||||||
#endif
|
#endif
|
||||||
if (graphics != NULL && !strcmp(graphics, "yes")) {
|
if (graphics != NULL && !strcmp(graphics, "yes")) {
|
||||||
// default scheme
|
int req_width = 0, req_height = 0, req_bpp = 0;
|
||||||
int margin = 64;
|
|
||||||
int margin_gradient = 20;
|
|
||||||
uint32_t colourscheme[] = {
|
|
||||||
0x00000000, // black
|
|
||||||
0x00aa0000, // red
|
|
||||||
0x0000aa00, // green
|
|
||||||
0x00aa5500, // brown
|
|
||||||
0x000000aa, // blue
|
|
||||||
0x00aa00aa, // magenta
|
|
||||||
0x0000aaaa, // cyan
|
|
||||||
0x00aaaaaa, // grey
|
|
||||||
0x00000000, // background (black)
|
|
||||||
0x00aaaaaa // foreground (grey)
|
|
||||||
};
|
|
||||||
|
|
||||||
char *colours = config_get_value(NULL, 0, "THEME_COLOURS");
|
char *menu_resolution = config_get_value(NULL, 0, "MENU_RESOLUTION");
|
||||||
if (colours == NULL)
|
if (menu_resolution != NULL)
|
||||||
colours = config_get_value(NULL, 0, "THEME_COLORS");
|
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
|
||||||
if (colours != NULL) {
|
|
||||||
const char *first = colours;
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 10; i++) {
|
|
||||||
const char *last;
|
|
||||||
uint32_t col = strtoui(first, &last, 16);
|
|
||||||
if (first == last)
|
|
||||||
break;
|
|
||||||
colourscheme[i] = col;
|
|
||||||
if (*last == 0)
|
|
||||||
break;
|
|
||||||
first = last + 1;
|
|
||||||
}
|
|
||||||
if (i < 8) {
|
|
||||||
colourscheme[8] = colourscheme[0];
|
|
||||||
colourscheme[9] = colourscheme[7];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *theme_margin = config_get_value(NULL, 0, "THEME_MARGIN");
|
term_vbe(req_width, req_height);
|
||||||
if (theme_margin != NULL) {
|
|
||||||
margin = strtoui(theme_margin, NULL, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *theme_margin_gradient = config_get_value(NULL, 0, "THEME_MARGIN_GRADIENT");
|
|
||||||
if (theme_margin_gradient != NULL) {
|
|
||||||
margin_gradient = strtoui(theme_margin_gradient, NULL, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct image *bg = NULL;
|
|
||||||
|
|
||||||
char *background_path = config_get_value(NULL, 0, "BACKGROUND_PATH");
|
|
||||||
if (background_path == NULL)
|
|
||||||
goto nobg;
|
|
||||||
|
|
||||||
struct file_handle *bg_file = ext_mem_alloc(sizeof(struct file_handle));
|
|
||||||
if (!uri_open(bg_file, background_path))
|
|
||||||
goto nobg;
|
|
||||||
|
|
||||||
bg = ext_mem_alloc(sizeof(struct image));
|
|
||||||
if (open_image(bg, bg_file))
|
|
||||||
bg = NULL;
|
|
||||||
|
|
||||||
nobg:
|
|
||||||
term_vbe(colourscheme, margin, margin_gradient, NULL);
|
|
||||||
|
|
||||||
if (bg != NULL) {
|
|
||||||
char *background_layout = config_get_value(NULL, 0, "BACKGROUND_STYLE");
|
|
||||||
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
|
|
||||||
char *background_colour = config_get_value(NULL, 0, "BACKDROP_COLOUR");
|
|
||||||
if (background_colour == NULL)
|
|
||||||
background_colour = config_get_value(NULL, 0, "BACKDROP_COLOR");
|
|
||||||
if (background_colour == NULL)
|
|
||||||
background_colour = "0";
|
|
||||||
uint32_t bg_col = strtoui(background_colour, NULL, 16);
|
|
||||||
image_make_centered(bg, fbinfo.framebuffer_width, fbinfo.framebuffer_height, bg_col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
term_vbe(colourscheme, margin, margin_gradient, bg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_cursor();
|
disable_cursor();
|
||||||
|
|
|
@ -269,27 +269,24 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
|
||||||
struct fb_info *fb = NULL;
|
struct fb_info *fb = NULL;
|
||||||
struct fb_info _fb;
|
struct fb_info _fb;
|
||||||
|
|
||||||
struct stivale2_header_tag_terminal *terminal_hdr_tag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_TERMINAL_ID);
|
|
||||||
|
|
||||||
struct stivale2_header_tag_framebuffer *hdrtag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_FRAMEBUFFER_ID);
|
struct stivale2_header_tag_framebuffer *hdrtag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_FRAMEBUFFER_ID);
|
||||||
|
|
||||||
|
int req_width, req_height, req_bpp;
|
||||||
|
|
||||||
|
if (hdrtag != NULL) {
|
||||||
|
req_width = hdrtag->framebuffer_width;
|
||||||
|
req_height = hdrtag->framebuffer_height;
|
||||||
|
req_bpp = hdrtag->framebuffer_bpp;
|
||||||
|
|
||||||
|
char *resolution = config_get_value(config, 0, "RESOLUTION");
|
||||||
|
if (resolution != NULL)
|
||||||
|
parse_resolution(&req_width, &req_height, &req_bpp, resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct stivale2_header_tag_terminal *terminal_hdr_tag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_TERMINAL_ID);
|
||||||
|
|
||||||
if (bits == 64 && terminal_hdr_tag != NULL && hdrtag != NULL) {
|
if (bits == 64 && terminal_hdr_tag != NULL && hdrtag != NULL) {
|
||||||
// If we're coming from some odd mode (text mode), reinitialise the graphical console
|
term_vbe(req_width, req_height);
|
||||||
if (current_video_mode < 0) {
|
|
||||||
uint32_t colourscheme[] = {
|
|
||||||
0x00000000, // black
|
|
||||||
0x00aa0000, // red
|
|
||||||
0x0000aa00, // green
|
|
||||||
0x00aa5500, // brown
|
|
||||||
0x000000aa, // blue
|
|
||||||
0x00aa00aa, // magenta
|
|
||||||
0x0000aaaa, // cyan
|
|
||||||
0x00aaaaaa, // grey
|
|
||||||
0x00000000, // background (black)
|
|
||||||
0x00aaaaaa // foreground (grey)
|
|
||||||
};
|
|
||||||
term_vbe(colourscheme, 64, 20, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current_video_mode < 0) {
|
if (current_video_mode < 0) {
|
||||||
panic("stivale2: Failed to initialise terminal");
|
panic("stivale2: Failed to initialise terminal");
|
||||||
|
@ -316,14 +313,6 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
|
||||||
if (hdrtag != NULL) {
|
if (hdrtag != NULL) {
|
||||||
term_deinit();
|
term_deinit();
|
||||||
|
|
||||||
int req_width = hdrtag->framebuffer_width;
|
|
||||||
int req_height = hdrtag->framebuffer_height;
|
|
||||||
int req_bpp = hdrtag->framebuffer_bpp;
|
|
||||||
|
|
||||||
char *resolution = config_get_value(config, 0, "RESOLUTION");
|
|
||||||
if (resolution != NULL)
|
|
||||||
parse_resolution(&req_width, &req_height, &req_bpp, resolution);
|
|
||||||
|
|
||||||
if (fb_init(fb, req_width, req_height, req_bpp)) {
|
if (fb_init(fb, req_width, req_height, req_bpp)) {
|
||||||
skip_modeset:;
|
skip_modeset:;
|
||||||
struct stivale2_struct_tag_framebuffer *tag = ext_mem_alloc(sizeof(struct stivale2_struct_tag_framebuffer));
|
struct stivale2_struct_tag_framebuffer *tag = ext_mem_alloc(sizeof(struct stivale2_struct_tag_framebuffer));
|
||||||
|
|
|
@ -3,7 +3,7 @@ TIMEOUT=3
|
||||||
GRAPHICS=yes
|
GRAPHICS=yes
|
||||||
MENU_FONT=boot:///boot/font.bin
|
MENU_FONT=boot:///boot/font.bin
|
||||||
|
|
||||||
THEME_COLOURS=000000;aa0000;00aaff;aa5500;0000aa;aa00aa;9076de;aaaaaa;60000000;aaaaaa
|
THEME_BACKGROUND=60000000
|
||||||
THEME_MARGIN=64
|
THEME_MARGIN=64
|
||||||
|
|
||||||
BACKGROUND_PATH=boot:///boot/bg.bmp
|
BACKGROUND_PATH=boot:///boot/bg.bmp
|
||||||
|
|
Loading…
Reference in New Issue