117ee9d00SSøren Schmidt /*- 217ee9d00SSøren Schmidt * Copyright (c) 1995 S�ren Schmidt 317ee9d00SSøren Schmidt * All rights reserved. 417ee9d00SSøren Schmidt * 517ee9d00SSøren Schmidt * Redistribution and use in source and binary forms, with or without 617ee9d00SSøren Schmidt * modification, are permitted provided that the following conditions 717ee9d00SSøren Schmidt * are met: 817ee9d00SSøren Schmidt * 1. Redistributions of source code must retain the above copyright 917ee9d00SSøren Schmidt * notice, this list of conditions and the following disclaimer 1017ee9d00SSøren Schmidt * in this position and unchanged. 1117ee9d00SSøren Schmidt * 2. Redistributions in binary form must reproduce the above copyright 1217ee9d00SSøren Schmidt * notice, this list of conditions and the following disclaimer in the 1317ee9d00SSøren Schmidt * documentation and/or other materials provided with the distribution. 1417ee9d00SSøren Schmidt * 3. The name of the author may not be used to endorse or promote products 1517ee9d00SSøren Schmidt * derived from this software withough specific prior written permission 1617ee9d00SSøren Schmidt * 1717ee9d00SSøren Schmidt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1817ee9d00SSøren Schmidt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1917ee9d00SSøren Schmidt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2017ee9d00SSøren Schmidt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2117ee9d00SSøren Schmidt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2217ee9d00SSøren Schmidt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2317ee9d00SSøren Schmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2417ee9d00SSøren Schmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2517ee9d00SSøren Schmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2617ee9d00SSøren Schmidt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2717ee9d00SSøren Schmidt * 2833b77e2dSBruce Evans * $Id: star_saver.c,v 1.12 1997/07/15 14:49:39 yokota Exp $ 2917ee9d00SSøren Schmidt */ 3017ee9d00SSøren Schmidt 3117ee9d00SSøren Schmidt #include <sys/param.h> 3217ee9d00SSøren Schmidt #include <sys/systm.h> 3317ee9d00SSøren Schmidt #include <sys/exec.h> 3417ee9d00SSøren Schmidt #include <sys/sysent.h> 3517ee9d00SSøren Schmidt #include <sys/lkm.h> 36f6b4ae3cSBruce Evans 37f6b4ae3cSBruce Evans #include <machine/md_var.h> 3833b77e2dSBruce Evans #include <machine/pc/display.h> 39f6b4ae3cSBruce Evans 40ce834215SKazutaka YOKOTA #include <saver.h> 4117ee9d00SSøren Schmidt 42b3e24f9cSBruce Evans MOD_MISC(star_saver); 4317ee9d00SSøren Schmidt 4417ee9d00SSøren Schmidt #define NUM_STARS 50 4517ee9d00SSøren Schmidt 4617ee9d00SSøren Schmidt /* 4717ee9d00SSøren Schmidt * Alternate saver that got its inspiration from a well known utility 4817ee9d00SSøren Schmidt * package for an inferior^H^H^H^H^H^Hfamous OS. 4917ee9d00SSøren Schmidt */ 50b3e24f9cSBruce Evans static void 5117ee9d00SSøren Schmidt star_saver(int blank) 5217ee9d00SSøren Schmidt { 5317ee9d00SSøren Schmidt scr_stat *scp = cur_console; 5417ee9d00SSøren Schmidt int cell, i; 5517ee9d00SSøren Schmidt char pattern[] = {"...........++++*** "}; 5617ee9d00SSøren Schmidt char colors[] = {FG_DARKGREY, FG_LIGHTGREY, 5717ee9d00SSøren Schmidt FG_WHITE, FG_LIGHTCYAN}; 5817ee9d00SSøren Schmidt static u_short stars[NUM_STARS][2]; 5917ee9d00SSøren Schmidt 6017ee9d00SSøren Schmidt if (blank) { 61ce834215SKazutaka YOKOTA if (scrn_blanked <= 0) { 6217ee9d00SSøren Schmidt scrn_blanked = 1; 6317ee9d00SSøren Schmidt fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat, 6417ee9d00SSøren Schmidt scp->xsize * scp->ysize); 6517ee9d00SSøren Schmidt set_border(0); 6617ee9d00SSøren Schmidt for(i=0; i<NUM_STARS; i++) { 6717ee9d00SSøren Schmidt stars[i][0] = 6817ee9d00SSøren Schmidt random() % (scp->xsize*scp->ysize); 6917ee9d00SSøren Schmidt stars[i][1] = 0; 7017ee9d00SSøren Schmidt } 7117ee9d00SSøren Schmidt } 7217ee9d00SSøren Schmidt cell = random() % NUM_STARS; 7317ee9d00SSøren Schmidt *((u_short*)(Crtat + stars[cell][0])) = 7417ee9d00SSøren Schmidt scr_map[pattern[stars[cell][1]]] | 7517ee9d00SSøren Schmidt colors[random()%sizeof(colors)] << 8; 7617ee9d00SSøren Schmidt if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { 7717ee9d00SSøren Schmidt stars[cell][0] = random() % (scp->xsize*scp->ysize); 7817ee9d00SSøren Schmidt stars[cell][1] = 0; 7917ee9d00SSøren Schmidt } 8017ee9d00SSøren Schmidt } 8117ee9d00SSøren Schmidt else { 82ce834215SKazutaka YOKOTA if (scrn_blanked > 0) { 8317ee9d00SSøren Schmidt set_border(scp->border); 8417ee9d00SSøren Schmidt scrn_blanked = 0; 8517ee9d00SSøren Schmidt } 8617ee9d00SSøren Schmidt } 8717ee9d00SSøren Schmidt } 8817ee9d00SSøren Schmidt 89b3e24f9cSBruce Evans static int 908e6b0117SPeter Wemm star_saver_load(struct lkm_table *lkmtp, int cmd) 9117ee9d00SSøren Schmidt { 92ce834215SKazutaka YOKOTA return add_scrn_saver(star_saver); 9317ee9d00SSøren Schmidt } 9417ee9d00SSøren Schmidt 95b3e24f9cSBruce Evans static int 968e6b0117SPeter Wemm star_saver_unload(struct lkm_table *lkmtp, int cmd) 9717ee9d00SSøren Schmidt { 98ce834215SKazutaka YOKOTA return remove_scrn_saver(star_saver); 9917ee9d00SSøren Schmidt } 10017ee9d00SSøren Schmidt 101b3e24f9cSBruce Evans int 1028e6b0117SPeter Wemm star_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 10317ee9d00SSøren Schmidt { 1040ddf9be1SPeter Dufault MOD_DISPATCH(star_saver, lkmtp, cmd, ver, 1050ddf9be1SPeter Dufault star_saver_load, star_saver_unload, lkm_nullcmd); 10617ee9d00SSøren Schmidt } 107