From ccd4815963fce6109d5a1feed1ef1b369094f5c3 Mon Sep 17 00:00:00 2001 From: Kazutaka YOKOTA Date: Mon, 29 Mar 1999 15:13:53 +0000 Subject: [PATCH] Make the splash screen alternate "fade out" and "fade in" action at regular intervals, when the module is used as a screen saver. Submitted by: asami --- sys/dev/fb/splash_bmp.c | 25 ++++++++++++++++++++----- sys/modules/splash/bmp/splash_bmp.c | 25 ++++++++++++++++++++----- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/sys/dev/fb/splash_bmp.c b/sys/dev/fb/splash_bmp.c index 71e25784720e..3b0e500677d5 100644 --- a/sys/dev/fb/splash_bmp.c +++ b/sys/dev/fb/splash_bmp.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: splash_bmp.c,v 1.5 1999/01/26 10:00:02 yokota Exp $ + * $Id: splash_bmp.c,v 1.6 1999/02/05 11:52:13 yokota Exp $ */ #include @@ -37,7 +37,8 @@ #include #include -#define FADE_TIMEOUT 300 /* sec */ +#define FADE_TIMEOUT 15 /* sec */ +#define FADE_LEVELS 10 static int splash_mode = -1; static int splash_on = FALSE; @@ -98,6 +99,8 @@ bmp_splash(video_adapter_t *adp, int on) { static u_char pal[256*3]; static long time_stamp; + u_char tpal[256*3]; + static int fading = TRUE, brightness = FADE_LEVELS; struct timeval tv; int i; @@ -122,11 +125,23 @@ bmp_splash(video_adapter_t *adp, int on) if (time_stamp == 0) time_stamp = tv.tv_sec; if (tv.tv_sec > time_stamp + FADE_TIMEOUT) { + if (fading) + if (brightness == 0) { + fading = FALSE; + brightness++; + } + else brightness--; + else + if (brightness == FADE_LEVELS) { + fading = TRUE; + brightness--; + } + else brightness++; for (i = 0; i < sizeof(pal); ++i) { - if (pal[i] > 40) - pal[i] -= 4; + tpal[i] = pal[i] * brightness / FADE_LEVELS; } - (*vidsw[adp->va_index]->load_palette)(adp, pal); + (*vidsw[adp->va_index]->load_palette)(adp, tpal); + time_stamp = tv.tv_sec; } } return 0; diff --git a/sys/modules/splash/bmp/splash_bmp.c b/sys/modules/splash/bmp/splash_bmp.c index 71e25784720e..3b0e500677d5 100644 --- a/sys/modules/splash/bmp/splash_bmp.c +++ b/sys/modules/splash/bmp/splash_bmp.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: splash_bmp.c,v 1.5 1999/01/26 10:00:02 yokota Exp $ + * $Id: splash_bmp.c,v 1.6 1999/02/05 11:52:13 yokota Exp $ */ #include @@ -37,7 +37,8 @@ #include #include -#define FADE_TIMEOUT 300 /* sec */ +#define FADE_TIMEOUT 15 /* sec */ +#define FADE_LEVELS 10 static int splash_mode = -1; static int splash_on = FALSE; @@ -98,6 +99,8 @@ bmp_splash(video_adapter_t *adp, int on) { static u_char pal[256*3]; static long time_stamp; + u_char tpal[256*3]; + static int fading = TRUE, brightness = FADE_LEVELS; struct timeval tv; int i; @@ -122,11 +125,23 @@ bmp_splash(video_adapter_t *adp, int on) if (time_stamp == 0) time_stamp = tv.tv_sec; if (tv.tv_sec > time_stamp + FADE_TIMEOUT) { + if (fading) + if (brightness == 0) { + fading = FALSE; + brightness++; + } + else brightness--; + else + if (brightness == FADE_LEVELS) { + fading = TRUE; + brightness--; + } + else brightness++; for (i = 0; i < sizeof(pal); ++i) { - if (pal[i] > 40) - pal[i] -= 4; + tpal[i] = pal[i] * brightness / FADE_LEVELS; } - (*vidsw[adp->va_index]->load_palette)(adp, pal); + (*vidsw[adp->va_index]->load_palette)(adp, tpal); + time_stamp = tv.tv_sec; } } return 0;