1 /*- 2 * Copyright (c) 1995-1998 S�ren Schmidt 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 * without modification, immediately at the beginning of the file. 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$ 29 */ 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/exec.h> 34 #include <sys/sysent.h> 35 #include <sys/lkm.h> 36 37 #include <machine/md_var.h> 38 #include <machine/pc/display.h> 39 40 #include <saver.h> 41 42 MOD_MISC(star_saver); 43 44 #define NUM_STARS 50 45 46 /* 47 * Alternate saver that got its inspiration from a well known utility 48 * package for an inferior^H^H^H^H^H^Hfamous OS. 49 */ 50 static void 51 star_saver(int blank) 52 { 53 scr_stat *scp = cur_console; 54 int cell, i; 55 char pattern[] = {"...........++++*** "}; 56 char colors[] = {FG_DARKGREY, FG_LIGHTGREY, 57 FG_WHITE, FG_LIGHTCYAN}; 58 static u_short stars[NUM_STARS][2]; 59 60 if (blank) { 61 if (scrn_blanked <= 0) { 62 scrn_blanked = 1; 63 fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat, 64 scp->xsize * scp->ysize); 65 set_border(scp, 0); 66 for(i=0; i<NUM_STARS; i++) { 67 stars[i][0] = 68 random() % (scp->xsize*scp->ysize); 69 stars[i][1] = 0; 70 } 71 } 72 cell = random() % NUM_STARS; 73 *((u_short*)(Crtat + stars[cell][0])) = 74 scr_map[pattern[stars[cell][1]]] | 75 colors[random()%sizeof(colors)] << 8; 76 if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { 77 stars[cell][0] = random() % (scp->xsize*scp->ysize); 78 stars[cell][1] = 0; 79 } 80 } 81 else { 82 if (scrn_blanked > 0) { 83 set_border(scp, scp->border); 84 scrn_blanked = 0; 85 } 86 } 87 } 88 89 static int 90 star_saver_load(struct lkm_table *lkmtp, int cmd) 91 { 92 if (cur_console->mode >= M_VESA_BASE) 93 return ENODEV; 94 95 return add_scrn_saver(star_saver); 96 } 97 98 static int 99 star_saver_unload(struct lkm_table *lkmtp, int cmd) 100 { 101 return remove_scrn_saver(star_saver); 102 } 103 104 int 105 star_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 106 { 107 MOD_DISPATCH(star_saver, lkmtp, cmd, ver, 108 star_saver_load, star_saver_unload, lkm_nullcmd); 109 } 110