summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-06-05 18:41:50 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-06-05 18:41:50 -0700
commitf6d5a4edb7bd591190973be3b681a4f944bdd265 (patch)
treed8e974c7d306b7e16f32f279bf825375d4d4493a
parente30e0e4951c0c666a12d4a6fce14b75b91615b43 (diff)
downloadsyslinux-f6d5a4edb7bd591190973be3b681a4f944bdd265.tar.gz
Allow a flat color to be specified as a background.
-rw-r--r--README.menu14
-rw-r--r--com32/include/syslinux/vesacon.h38
-rw-r--r--com32/lib/sys/vesa/background.c60
-rw-r--r--com32/modules/menu.c6
-rw-r--r--com32/modules/menu.h3
-rw-r--r--com32/modules/menumain.c5
-rw-r--r--com32/modules/printmsg.c2
-rw-r--r--com32/modules/readconfig.c2
-rw-r--r--com32/modules/vesamenu.c15
9 files changed, 107 insertions, 38 deletions
diff --git a/README.menu b/README.menu
index 3cfeacaf..3fd50f3c 100644
--- a/README.menu
+++ b/README.menu
@@ -118,10 +118,12 @@ MENU MASTER PASSWD passwd
work.
-MENU BACKGROUND filename
+MENU BACKGROUND background
- For vesamenu.c32, sets the background image. The image should
- be 640x480 pixels and either in PNG or JPEG format.
+ For vesamenu.c32, sets the background image. The background
+ can either be a color (see MENU COLOR) or the name of an image
+ file, which should be 640x480 pixels and either in PNG or JPEG
+ format.
INCLUDE filename
@@ -289,16 +291,16 @@ MENU VSHIFT 0
screen (25 for text mode, 28 for VESA graphics mode.)
-F1 textfile background_file
+F1 textfile background
...
-F12 textfile background_file
+F12 textfile background
Displays full-screen help (also available at the command line.)
The same control code sequences as in the command line
interface are supported, although some are ignored.
Additionally, a second argument allows a different background
- image file (see MENU BACKGROUND) to be displayed.
+ image (see MENU BACKGROUND for supported formats) to be displayed.
The menu system honours the TIMEOUT command; if TIMEOUT is specified
diff --git a/com32/include/syslinux/vesacon.h b/com32/include/syslinux/vesacon.h
new file mode 100644
index 00000000..fd25fa19
--- /dev/null
+++ b/com32/include/syslinux/vesacon.h
@@ -0,0 +1,38 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2007 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef _SYSLINUX_VESACON_H
+#define _SYSLINUX_VESACON_H
+
+int vesacon_default_background(void);
+int vesacon_load_background(const char *);
+int vesacon_set_background(unsigned int);
+
+#endif /* _SYSLINUX_VESACON_H */
+
+
+
diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c
index 91c5424b..586ee2ea 100644
--- a/com32/lib/sys/vesa/background.c
+++ b/com32/lib/sys/vesa/background.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 2006 H. Peter Anvin - All Rights Reserved
+ * Copyright 2006-2007 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -46,7 +46,7 @@ static size_t filesize(FILE *fp)
return st.st_size;
}
-/*** FIX: This really should be alpha-blended with color index 0 */
+/*** FIX: This really should be alpha-blended with color index 0 ***/
/* For best performance, "start" should be a multiple of 4, to assure
aligned dwords. */
@@ -228,12 +228,15 @@ static int read_jpeg_file(FILE *fp, uint8_t *header, int len)
}
/* Simple grey Gaussian hole, enough to look interesting */
-static void default_background(void)
+int vesacon_default_background(void)
{
int x, y, dx, dy, dy2;
uint8_t *bgptr = (uint8_t *)&__vesacon_background;
uint8_t k;
+ if (__vesacon_pixel_format == PXF_NONE)
+ return 0; /* Not in graphics mode */
+
for (y = 0, dy = -VIDEO_Y_SIZE/2; y < VIDEO_Y_SIZE; y++, dy++) {
dy2 = dy*dy;
for (x = 0, dx = -VIDEO_X_SIZE/2; x < VIDEO_X_SIZE; x++, dx++) {
@@ -244,6 +247,27 @@ static void default_background(void)
bgptr += 4; /* Dummy alpha */
}
}
+
+ draw_background();
+ return 0;
+}
+
+/* Set the background to a single flat color */
+int vesacon_set_background(unsigned int rgb)
+{
+ void *bgptr = __vesacon_background;
+ unsigned int count = VIDEO_X_SIZE*VIDEO_Y_SIZE;
+
+ if (__vesacon_pixel_format == PXF_NONE)
+ return 0; /* Not in graphics mode */
+
+ asm("cld; rep; stosl"
+ : "+D" (bgptr), "+c" (count)
+ : "a" (rgb)
+ : "memory");
+
+ draw_background();
+ return 0;
}
int vesacon_load_background(const char *filename)
@@ -255,31 +279,27 @@ int vesacon_load_background(const char *filename)
if (__vesacon_pixel_format == PXF_NONE)
return 0; /* Not in graphics mode */
- if (!filename) {
- default_background();
- } else {
- fp = fopen(filename, "r");
-
- if (!fp)
- goto err;
-
- if (fread(header, 1, 8, fp) != 8)
- goto err;
+ fp = fopen(filename, "r");
- if (!png_sig_cmp(header, 0, 8)) {
- rv = read_png_file(fp);
- } else if (!jpeg_sig_cmp(header, 8)) {
- rv = read_jpeg_file(fp, header, 8);
- }
+ if (!fp)
+ goto err;
+
+ if (fread(header, 1, 8, fp) != 8)
+ goto err;
+
+ if (!png_sig_cmp(header, 0, 8)) {
+ rv = read_png_file(fp);
+ } else if (!jpeg_sig_cmp(header, 8)) {
+ rv = read_jpeg_file(fp, header, 8);
}
/* This actually displays the stuff */
draw_background();
-
+
err:
if (fp)
fclose(fp);
-
+
return rv;
}
diff --git a/com32/modules/menu.c b/com32/modules/menu.c
index 1f2c5103..17411504 100644
--- a/com32/modules/menu.c
+++ b/com32/modules/menu.c
@@ -30,6 +30,12 @@ void console_cleanup(void)
/* Nothing special to do */
}
+int draw_background(const char *arg)
+{
+ /* Nothing to do... */
+ (void)arg;
+}
+
int main(int argc, char *argv[])
{
console_ansi_raw();
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index 933df43c..17fa554b 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -112,7 +112,7 @@ struct fkey_help {
extern struct fkey_help fkeyhelp[12];
void parse_configs(char **argv);
-extern int (*draw_background)(const char *filename);
+int draw_background(const char *filename);
static inline int my_isspace(char c)
{
@@ -122,6 +122,7 @@ static inline int my_isspace(char c)
int my_isxdigit(char c);
unsigned int hexval(char c);
unsigned int hexval2(const char *p);
+uint32_t parse_argb(char **p);
int menu_main(int argc, char *argv[]);
void console_prepare(void);
diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c
index f5d2dd33..4faaabdf 100644
--- a/com32/modules/menumain.c
+++ b/com32/modules/menumain.c
@@ -34,8 +34,6 @@
#include "menu.h"
-int (*draw_background)(const char *filename);
-
/*
* The color/attribute indexes (\1#X, \2#XX, \3#XXX) are as follows
*
@@ -1079,8 +1077,7 @@ int menu_main(int argc, char *argv[])
if (mparm[i].value < 0)
mparm[i].value = max(mparm[i].value+rows, 0);
- if (draw_background)
- draw_background(menu_background);
+ draw_background(menu_background);
if ( !nentries ) {
fputs("No LABEL entries found in configuration file!\n", stdout);
diff --git a/com32/modules/printmsg.c b/com32/modules/printmsg.c
index 73682039..dbda84eb 100644
--- a/com32/modules/printmsg.c
+++ b/com32/modules/printmsg.c
@@ -17,8 +17,6 @@
#include "menu.h"
-int (*draw_background)(const char *filename);
-
static int draw_message_file(const char *filename)
{
FILE *f;
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index c9453a4b..dc604df1 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -337,7 +337,7 @@ unsigned int hexval2(const char *p)
return (hexval(p[0]) << 4)+hexval(p[1]);
}
-static uint32_t parse_argb(char **p)
+uint32_t parse_argb(char **p)
{
char *sp = *p;
char *ep;
diff --git a/com32/modules/vesamenu.c b/com32/modules/vesamenu.c
index 709e5e55..6455f97e 100644
--- a/com32/modules/vesamenu.c
+++ b/com32/modules/vesamenu.c
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <console.h>
+#include <syslinux/vesacon.h>
+
#include "menu.h"
void console_prepare(void)
@@ -34,13 +36,18 @@ void console_cleanup(void)
fputs("\033[0m\033[20l", stdout);
}
-int vesacon_load_background(const char *);
+int draw_background(const char *what)
+{
+ if (!what)
+ return vesacon_default_background();
+ else if (what[0] == '#')
+ return vesacon_set_background(parse_argb((char **)&what));
+ else
+ return vesacon_load_background(what);
+}
int main(int argc, char *argv[])
{
openconsole(&dev_rawcon_r, &dev_vesaserial_w);
-
- draw_background = vesacon_load_background;
-
return menu_main(argc, argv);
}