logo_saver.c (42120) | logo_saver.c (42236) |
---|---|
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 --- 11 unchanged lines hidden (view full) --- 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 --- 11 unchanged lines hidden (view full) --- 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$ | 28 * $Id: logo_saver.c,v 1.1 1998/12/28 14:22: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> 36 37#include <machine/md_var.h> 38 39#include <saver.h> 40 41static u_char *vid; | 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 <machine/md_var.h> 38 39#include <saver.h> 40 41static u_char *vid; |
42static int banksize; | 42static int banksize, scrmode, scrw, scrh; |
43static u_char save_pal[768]; 44 | 43static u_char save_pal[768]; 44 |
45#define SCRW 800 46#define SCRH 600 47 | |
48#include "logo.c" 49 50#define set_origin(scp, o) (*biosvidsw.set_win_org)((scp)->adp, o) 51 52static void 53logo_blit(int x, int y) 54{ 55 int d, l, o, p; 56 | 45#include "logo.c" 46 47#define set_origin(scp, o) (*biosvidsw.set_win_org)((scp)->adp, o) 48 49static void 50logo_blit(int x, int y) 51{ 52 int d, l, o, p; 53 |
57 for (o = 0, p = y * SCRW + x; p > banksize; p -= banksize) | 54 for (o = 0, p = y * scrw + x; p > banksize; p -= banksize) |
58 o += banksize; 59 set_origin(cur_console, o); 60 61 for (d = 0; d < sizeof logo_img; d += logo_w) { 62 if (p + logo_w < banksize) { 63 bcopy(logo_img + d, vid + p, logo_w); | 55 o += banksize; 56 set_origin(cur_console, 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); |
64 p += SCRW; | 61 p += scrw; |
65 } else if (p < banksize) { 66 l = banksize - p; 67 bcopy(logo_img + d, vid + p, l); 68 set_origin(cur_console, (o += banksize)); 69 bcopy(logo_img + d + l, vid, logo_w - l); | 62 } else if (p < banksize) { 63 l = banksize - p; 64 bcopy(logo_img + d, vid + p, l); 65 set_origin(cur_console, (o += banksize)); 66 bcopy(logo_img + d + l, vid, logo_w - l); |
70 p += SCRW - banksize; | 67 p += scrw - banksize; |
71 } else { 72 p -= banksize; 73 set_origin(cur_console, (o += banksize)); 74 bcopy(logo_img + d, vid + p, logo_w); | 68 } else { 69 p -= banksize; 70 set_origin(cur_console, (o += banksize)); 71 bcopy(logo_img + d, vid + p, logo_w); |
75 p += SCRW; | 72 p += scrw; |
76 } 77 } 78} 79 80static void 81logo_update(void) 82{ 83 static int xpos = 0, ypos = 0; 84 static int xinc = 1, yinc = 1; 85 86 /* Turn when you hit the edge */ | 73 } 74 } 75} 76 77static void 78logo_update(void) 79{ 80 static int xpos = 0, ypos = 0; 81 static int xinc = 1, yinc = 1; 82 83 /* Turn when you hit the edge */ |
87 if ((xpos + logo_w + xinc > SCRW) || (xpos + xinc < 0)) xinc = -xinc; 88 if ((ypos + logo_h + yinc > SCRH) || (ypos + yinc < 0)) yinc = -yinc; 89 xpos += xinc; ypos += yinc; | 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(xpos, ypos); 93} 94 95static void 96logo_saver(int blank) 97{ 98 scr_stat *scp = cur_console; 99 static int saved_mode; | 90 91 /* XXX Relies on margin around logo to erase trail */ 92 logo_blit(xpos, ypos); 93} 94 95static void 96logo_saver(int blank) 97{ 98 scr_stat *scp = cur_console; 99 static int saved_mode; |
100 int pl; | 100 int i, pl; |
101 102 if (blank) { 103 /* switch to graphics mode */ 104 if (scrn_blanked <= 0) { 105 pl = splhigh(); 106 saved_mode = scp->mode; | 101 102 if (blank) { 103 /* switch to graphics mode */ 104 if (scrn_blanked <= 0) { 105 pl = splhigh(); 106 saved_mode = scp->mode; |
107 scp->mode = M_VESA_CG800x600; | 107 scp->mode = scrmode; |
108 scp->status |= SAVER_RUNNING|GRAPHICS_MODE; 109 save_palette(scp, (char *)save_pal); 110 set_mode(scp); 111 load_palette(scp, (char *)logo_pal); 112 scrn_blanked++; 113 vid = (u_char *)Crtat; 114 splx(pl); | 108 scp->status |= SAVER_RUNNING|GRAPHICS_MODE; 109 save_palette(scp, (char *)save_pal); 110 set_mode(scp); 111 load_palette(scp, (char *)logo_pal); 112 scrn_blanked++; 113 vid = (u_char *)Crtat; 114 splx(pl); |
115 /* XXX should clear all banks */ | 115 for (i = 0; i < scrw*scrh; i += banksize) { 116 set_origin(scp, i); 117 bzero(vid, banksize); 118 } |
116 } 117 logo_update(); 118 } else { 119 /* return to previous video mode */ 120 if (scrn_blanked > 0) { 121 if (saved_mode) { 122 pl = splhigh(); 123 scrn_blanked = 0; --- 7 unchanged lines hidden (view full) --- 131 } 132 } 133} 134 135static int 136logo_saver_load(void) 137{ 138 video_info_t info; | 119 } 120 logo_update(); 121 } else { 122 /* return to previous video mode */ 123 if (scrn_blanked > 0) { 124 if (saved_mode) { 125 pl = splhigh(); 126 scrn_blanked = 0; --- 7 unchanged lines hidden (view full) --- 134 } 135 } 136} 137 138static int 139logo_saver_load(void) 140{ 141 video_info_t info; |
139 140 /* check that the console is capable of running in 800x600x256 */ 141 if ((*biosvidsw.get_info)(cur_console->adp, M_VESA_CG800x600, &info)) { 142 log(LOG_NOTICE, "logo_saver: the console does not support M_VESA_CG800x600\n"); | 142 int adp; 143 144 adp = cur_console->adp; 145 if (!(*biosvidsw.get_info)(adp, M_VESA_CG800x600, &info)) { 146 scrmode = M_VESA_CG800x600; 147 } else if (!(*biosvidsw.get_info)(adp, M_VGA_CG320, &info)) { 148 scrmode = M_VGA_CG320; 149 } else { 150 log(LOG_NOTICE, "logo_saver: no suitable graphics mode\n"); |
143 return ENODEV; 144 } 145 | 151 return ENODEV; 152 } 153 |
146 /* is it possible for window_size not to be a multiple of window_gran? */ 147 while (banksize + info.vi_window_gran <= info.vi_window_size) 148 banksize += info.vi_window_gran; 149 | 154 banksize = info.vi_window_size; 155 scrw = info.vi_width; 156 scrh = info.vi_height; 157 |
150 return add_scrn_saver(logo_saver); 151} 152 153static int 154logo_saver_unload(void) 155{ 156 return remove_scrn_saver(logo_saver); 157} 158 159SAVER_MODULE(logo_saver); | 158 return add_scrn_saver(logo_saver); 159} 160 161static int 162logo_saver_unload(void) 163{ 164 return remove_scrn_saver(logo_saver); 165} 166 167SAVER_MODULE(logo_saver); |