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 *
| 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.5 1999/02/05 12:40:15 des Exp $
| 28 * $Id: logo_saver.c,v 1.6 1999/04/12 13:34:57 des 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>
| 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#include <sys/consio.h> 37#include <sys/fbio.h>
|
36
| 38
|
37#include <saver.h>
| 39#include <dev/fb/fbreg.h> 40#include <dev/fb/splashreg.h> 41#include <dev/syscons/syscons.h>
|
38 39static u_char *vid; 40static int banksize, scrmode, bpsl, scrw, scrh; 41static int blanked; 42 43#include "logo.c" 44 45static void 46logo_blit(video_adapter_t *adp, int x, int y) 47{ 48 int d, l, o, p; 49 50 for (o = 0, p = y * bpsl + 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 += bpsl; 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 += bpsl - banksize; 64 } else { 65 p -= banksize; 66 set_origin(adp, (o += banksize)); 67 bcopy(logo_img + d, vid + p, logo_w); 68 p += bpsl; 69 } 70 } 71} 72 73static void 74logo_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 91static int 92logo_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); 101 load_palette(adp, logo_pal); 102#if 0 /* XXX conflict */ 103 set_border(adp, 0); 104#endif 105 blanked++; 106 vid = (u_char *)adp->va_window;
| 42 43static u_char *vid; 44static int banksize, scrmode, bpsl, scrw, scrh; 45static int blanked; 46 47#include "logo.c" 48 49static void 50logo_blit(video_adapter_t *adp, int x, int y) 51{ 52 int d, l, o, p; 53 54 for (o = 0, p = y * bpsl + x; p > banksize; p -= banksize) 55 o += banksize; 56 set_origin(adp, o); 57 58 for (d = 0; d < sizeof logo_img; d += logo_w) { 59 if (p + logo_w < banksize) { 60 bcopy(logo_img + d, vid + p, logo_w); 61 p += bpsl; 62 } else if (p < banksize) { 63 l = banksize - p; 64 bcopy(logo_img + d, vid + p, l); 65 set_origin(adp, (o += banksize)); 66 bcopy(logo_img + d + l, vid, logo_w - l); 67 p += bpsl - banksize; 68 } else { 69 p -= banksize; 70 set_origin(adp, (o += banksize)); 71 bcopy(logo_img + d, vid + p, logo_w); 72 p += bpsl; 73 } 74 } 75} 76 77static void 78logo_update(video_adapter_t *adp) 79{ 80 static int xpos = 0, ypos = 0; 81 static int xinc = 1, yinc = 1; 82 83 /* Turn when you hit the edge */ 84 if ((xpos + logo_w + xinc > scrw) || (xpos + xinc < 0)) 85 xinc = -xinc; 86 if ((ypos + logo_h + yinc > scrh) || (ypos + yinc < 0)) 87 yinc = -yinc; 88 xpos += xinc; 89 ypos += yinc; 90 91 /* XXX Relies on margin around logo to erase trail */ 92 logo_blit(adp, xpos, ypos); 93} 94 95static int 96logo_saver(video_adapter_t *adp, int blank) 97{ 98 int i, pl; 99 100 if (blank) { 101 /* switch to graphics mode */ 102 if (blanked <= 0) { 103 pl = splhigh(); 104 set_video_mode(adp, scrmode); 105 load_palette(adp, logo_pal); 106#if 0 /* XXX conflict */ 107 set_border(adp, 0); 108#endif 109 blanked++; 110 vid = (u_char *)adp->va_window;
|
| 111 banksize = adp->va_window_size;
|
107 bpsl = adp->va_line_width; 108 splx(pl); 109 for (i = 0; i < bpsl*scrh; i += banksize) { 110 set_origin(adp, i); 111 bzero(vid, banksize); 112 } 113 } 114 logo_update(adp); 115 } else { 116 blanked = 0; 117 } 118 return 0; 119} 120 121static int 122logo_init(video_adapter_t *adp) 123{ 124 video_info_t info; 125 126 if (!get_mode_info(adp, M_VESA_CG800x600, &info)) { 127 scrmode = M_VESA_CG800x600; 128 } else if (!get_mode_info(adp, M_VGA_CG320, &info)) { 129 scrmode = M_VGA_CG320; 130 } else { 131 log(LOG_NOTICE, "logo_saver: no suitable graphics mode\n"); 132 return ENODEV; 133 } 134
| 112 bpsl = adp->va_line_width; 113 splx(pl); 114 for (i = 0; i < bpsl*scrh; i += banksize) { 115 set_origin(adp, i); 116 bzero(vid, banksize); 117 } 118 } 119 logo_update(adp); 120 } else { 121 blanked = 0; 122 } 123 return 0; 124} 125 126static int 127logo_init(video_adapter_t *adp) 128{ 129 video_info_t info; 130 131 if (!get_mode_info(adp, M_VESA_CG800x600, &info)) { 132 scrmode = M_VESA_CG800x600; 133 } else if (!get_mode_info(adp, M_VGA_CG320, &info)) { 134 scrmode = M_VGA_CG320; 135 } else { 136 log(LOG_NOTICE, "logo_saver: no suitable graphics mode\n"); 137 return ENODEV; 138 } 139
|
135 banksize = info.vi_window_size;
| |
136 scrw = info.vi_width; 137 scrh = info.vi_height; 138 blanked = 0; 139 140 return 0; 141} 142 143static int 144logo_term(video_adapter_t *adp) 145{ 146 return 0; 147} 148 149static scrn_saver_t logo_module = { 150 "logo_saver", logo_init, logo_term, logo_saver, NULL, 151}; 152 153SAVER_MODULE(logo_saver, logo_module);
| 140 scrw = info.vi_width; 141 scrh = info.vi_height; 142 blanked = 0; 143 144 return 0; 145} 146 147static int 148logo_term(video_adapter_t *adp) 149{ 150 return 0; 151} 152 153static scrn_saver_t logo_module = { 154 "logo_saver", logo_init, logo_term, logo_saver, NULL, 155}; 156 157SAVER_MODULE(logo_saver, logo_module);
|