star_saver.c revision 174985
16628Ssos/*- 239287Ssos * Copyright (c) 1995-1998 S�ren Schmidt 36628Ssos * All rights reserved. 46628Ssos * 56628Ssos * Redistribution and use in source and binary forms, with or without 66628Ssos * modification, are permitted provided that the following conditions 76628Ssos * are met: 86628Ssos * 1. Redistributions of source code must retain the above copyright 939287Ssos * notice, this list of conditions and the following disclaimer, 1039287Ssos * without modification, immediately at the beginning of the file. 116628Ssos * 2. Redistributions in binary form must reproduce the above copyright 126628Ssos * notice, this list of conditions and the following disclaimer in the 136628Ssos * documentation and/or other materials provided with the distribution. 146628Ssos * 3. The name of the author may not be used to endorse or promote products 1539287Ssos * derived from this software without specific prior written permission. 166628Ssos * 176628Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 186628Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 196628Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 206628Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 216628Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 226628Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236628Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246628Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256628Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 266628Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276628Ssos * 2850477Speter * $FreeBSD: head/sys/dev/syscons/star/star_saver.c 174985 2007-12-29 23:26:59Z wkoszek $ 296628Ssos */ 306628Ssos 316628Ssos#include <sys/param.h> 326628Ssos#include <sys/systm.h> 3340885Speter#include <sys/kernel.h> 3440885Speter#include <sys/module.h> 3548104Syokota#include <sys/consio.h> 3648104Syokota#include <sys/fbio.h> 376628Ssos 3832571Sbde#include <machine/pc/display.h> 3916879Sbde 4048104Syokota#include <dev/fb/fbreg.h> 4148104Syokota#include <dev/fb/splashreg.h> 4248104Syokota#include <dev/syscons/syscons.h> 4316879Sbde 446628Ssos#define NUM_STARS 50 456628Ssos 4642504Syokotastatic int blanked; 4739428Ssos 486628Ssos/* 496628Ssos * Alternate saver that got its inspiration from a well known utility 506628Ssos * package for an inferior^H^H^H^H^H^Hfamous OS. 516628Ssos */ 5242504Syokotastatic int 5342504Syokotastar_saver(video_adapter_t *adp, int blank) 546628Ssos{ 5548104Syokota sc_softc_t *sc; 5648104Syokota scr_stat *scp; 576628Ssos int cell, i; 5872797Snyan static u_char pattern[] = {"...........++++*** "}; 59146239Snyan static char color16[] = {FG_DARKGREY, FG_LIGHTGREY, 60146239Snyan FG_WHITE, FG_LIGHTCYAN}; 61146239Snyan static char color8[] = {FG_BLUE, FG_BROWN, 6248104Syokota FG_LIGHTGREY, FG_CYAN}; 63146239Snyan static char *colors; 646628Ssos static u_short stars[NUM_STARS][2]; 658871Srgrimes 6648104Syokota sc = sc_find_softc(adp, NULL); 6748104Syokota if (sc == NULL) 6848104Syokota return EAGAIN; 6948104Syokota scp = sc->cur_scp; 7048104Syokota 716628Ssos if (blank) { 7243673Sdes if (adp->va_info.vi_flags & V_INFO_GRAPHICS) 7342749Syokota return EAGAIN; 7442504Syokota if (!blanked) { 75146239Snyan switch (adp->va_mode) { 76146239Snyan case M_PC98_80x25: 77146239Snyan case M_PC98_80x30: 78146239Snyan colors = color8; 79146239Snyan break; 80146239Snyan default: 81146239Snyan colors = color16; 82146239Snyan break; 8348104Syokota } 84146239Snyan 8542504Syokota /* clear the screen and set the border color */ 8648104Syokota sc_vtb_clear(&scp->scr, sc->scr_map[0x20], 8748104Syokota (FG_LIGHTGREY | BG_BLACK) << 8); 88174985Swkoszek vidd_set_hw_cursor(adp, -1, -1); 8956043Syokota sc_set_border(scp, 0); 9042504Syokota blanked = TRUE; 916628Ssos for(i=0; i<NUM_STARS; i++) { 928871Srgrimes stars[i][0] = 936628Ssos random() % (scp->xsize*scp->ysize); 946628Ssos stars[i][1] = 0; 956628Ssos } 966628Ssos } 976628Ssos cell = random() % NUM_STARS; 9848104Syokota sc_vtb_putc(&scp->scr, stars[cell][0], 9948104Syokota sc->scr_map[pattern[stars[cell][1]]], 100146239Snyan colors[random()%sizeof(color16)] << 8); 1016628Ssos if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { 1026628Ssos stars[cell][0] = random() % (scp->xsize*scp->ysize); 1036628Ssos stars[cell][1] = 0; 1046628Ssos } 105146239Snyan } else 10642504Syokota blanked = FALSE; 107146239Snyan 10842504Syokota return 0; 1096628Ssos} 1106628Ssos 11112276Sbdestatic int 11242504Syokotastar_init(video_adapter_t *adp) 1136628Ssos{ 11442504Syokota blanked = FALSE; 11542504Syokota return 0; 1166628Ssos} 1176628Ssos 11812276Sbdestatic int 11942504Syokotastar_term(video_adapter_t *adp) 1206628Ssos{ 12142504Syokota return 0; 1226628Ssos} 1236628Ssos 12442504Syokotastatic scrn_saver_t star_module = { 12542504Syokota "star_saver", star_init, star_term, star_saver, NULL, 12642504Syokota}; 12742504Syokota 12842504SyokotaSAVER_MODULE(star_saver, star_module); 129