1 /*- 2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * $Id: logo_saver.c,v 1.3 1999/01/11 03:18:49 yokota Exp $ 29 */ 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/kernel.h> 34 #include <sys/module.h> 35 #include <sys/syslog.h> 36 37 #include <saver.h> 38 39 static u_char *vid; 40 static int banksize, scrmode, scrw, scrh; 41 static int blanked; 42 43 #include "logo.c" 44 45 static void 46 logo_blit(video_adapter_t *adp, int x, int y) 47 { 48 int d, l, o, p; 49 50 for (o = 0, p = y * scrw + x; p > banksize; p -= banksize) 51 o += banksize; 52 set_origin(adp, o); 53 54 for (d = 0; d < sizeof logo_img; d += logo_w) { 55 if (p + logo_w < banksize) { 56 bcopy(logo_img + d, vid + p, logo_w); 57 p += scrw; 58 } else if (p < banksize) { 59 l = banksize - p; 60 bcopy(logo_img + d, vid + p, l); 61 set_origin(adp, (o += banksize)); 62 bcopy(logo_img + d + l, vid, logo_w - l); 63 p += scrw - banksize; 64 } else { 65 p -= banksize; 66 set_origin(adp, (o += banksize)); 67 bcopy(logo_img + d, vid + p, logo_w); 68 p += scrw; 69 } 70 } 71 } 72 73 static void 74 logo_update(video_adapter_t *adp) 75 { 76 static int xpos = 0, ypos = 0; 77 static int xinc = 1, yinc = 1; 78 79 /* Turn when you hit the edge */ 80 if ((xpos + logo_w + xinc > scrw) || (xpos + xinc < 0)) 81 xinc = -xinc; 82 if ((ypos + logo_h + yinc > scrh) || (ypos + yinc < 0)) 83 yinc = -yinc; 84 xpos += xinc; 85 ypos += yinc; 86 87 /* XXX Relies on margin around logo to erase trail */ 88 logo_blit(adp, xpos, ypos); 89 } 90 91 static int 92 logo_saver(video_adapter_t *adp, int blank) 93 { 94 int i, pl; 95 96 if (blank) { 97 /* switch to graphics mode */ 98 if (blanked <= 0) { 99 pl = splhigh(); 100 set_video_mode(adp, scrmode, logo_pal, 0); 101 blanked++; 102 vid = (u_char *)adp->va_window; 103 splx(pl); 104 for (i = 0; i < scrw*scrh; i += banksize) { 105 set_origin(adp, i); 106 bzero(vid, banksize); 107 } 108 } 109 logo_update(adp); 110 } else { 111 blanked = 0; 112 } 113 return 0; 114 } 115 116 static int 117 logo_init(video_adapter_t *adp) 118 { 119 video_info_t info; 120 121 if (!get_mode_info(adp, M_VESA_CG800x600, &info)) { 122 scrmode = M_VESA_CG800x600; 123 } else if (!get_mode_info(adp, M_VGA_CG320, &info)) { 124 scrmode = M_VGA_CG320; 125 } else { 126 log(LOG_NOTICE, "logo_saver: no suitable graphics mode\n"); 127 return ENODEV; 128 } 129 130 banksize = info.vi_window_size; 131 scrw = info.vi_width; 132 scrh = info.vi_height; 133 blanked = 0; 134 135 return 0; 136 } 137 138 static int 139 logo_term(video_adapter_t *adp) 140 { 141 return 0; 142 } 143 144 static scrn_saver_t logo_module = { 145 "logo_saver", logo_init, logo_term, logo_saver, NULL, 146 }; 147 148 SAVER_MODULE(logo_saver, logo_module); 149