aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/sys/vesa/background.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-09-14 14:43:44 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-09-14 14:43:44 -0700
commitc282957e1ab8c23d881c93f54e478b051896c721 (patch)
tree453d31d41b0a4e273d44711a8412c7690ba99199 /com32/lib/sys/vesa/background.c
parentf97a0cfda277f0651d7cc2d59733c81796b7cc89 (diff)
downloadsyslinux-c282957e1ab8c23d881c93f54e478b051896c721.tar.gz
syslinux-c282957e1ab8c23d881c93f54e478b051896c721.tar.xz
syslinux-c282957e1ab8c23d881c93f54e478b051896c721.zip
Default background; skip background if VESA is uninitializedsyslinux-3.30-pre7
Diffstat (limited to 'com32/lib/sys/vesa/background.c')
-rw-r--r--com32/lib/sys/vesa/background.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c
index 2e5b108f..2dccfce9 100644
--- a/com32/lib/sys/vesa/background.c
+++ b/com32/lib/sys/vesa/background.c
@@ -239,29 +239,50 @@ static int read_jpeg_file(FILE *fp, uint8_t *header, int len)
return rv;
}
+/* Simple grey Gaussian hole, enough to look interesting */
+static void default_background(void)
+{
+ int x, y, dx, dy, dy2;
+ uint8_t *bgptr = (uint8_t *)&__vesacon_background;
+ uint8_t c;
+
+ 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++) {
+ c = ((dx*dx+dy2) >> 11) + 88;
+ *bgptr++ = c;
+ *bgptr++ = c;
+ *bgptr++ = c;
+ bgptr++; /* Dummy alpha */
+ }
+ }
+}
+
int vesacon_load_background(const char *filename)
{
- FILE *fp;
+ FILE *fp = NULL;
uint8_t header[8];
int rv = 1;
- if (!filename) {
- draw_background();
- return 0;
- }
-
- fp = fopen(filename, "r");
+ if (__vesacon_pixel_format == PXF_NONE)
+ return 0; /* Not in graphics mode */
- 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);
+ if (!filename) {
+ default_background();
+ } else {
+ fp = fopen(filename, "r");
+
+ 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 */