Date: Mon, 5 Nov 2001 19:15:17 -0800 From: Marcus Reid <marcus@blazingdot.com> To: Dag-Erling Smorgrav <des@ofug.org> Cc: freebsd-chat@FreeBSD.Org Subject: Re: simplicity_saver Message-ID: <20011105191517.A25268@blazingdot.com> In-Reply-To: <xzp8zdkd664.fsf@flood.ping.uio.no>; from des@ofug.org on Tue, Nov 06, 2001 at 02:44:35AM %2B0100 References: <20011104151840.A13030@blazingdot.com> <xzpg07sdbtb.fsf@flood.ping.uio.no> <20011105171840.E20245@blazingdot.com> <xzp8zdkd664.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
--sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 06, 2001 at 02:44:35AM +0100, Dag-Erling Smorgrav wrote: > Marcus Reid <marcus@blazingdot.com> writes: > > Something calls simplicity_saver() with blank != 0 when the screensaver > > needs to be displayed, for each frame of animation. The first time through, > > the palette is set, and each additional time that part is skipped. When > > finally (someone presses a key or something and) simplicity_saver() is > > called with blank = 0, blanked is set back to 0 so that the palette and > > video mode are set next time they're needed. > > The palette (k_pal) is a static array and only needs to be initialized > once. You need to *load* it every time you blank the screen, but you > only need to initialize it once. Right you are.. Looks like I propagated a mistake that was made in fire_saver.c. New version attached, other cleanups included. Thanks. -- Marcus Reid Blazingdot "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin, 1759 --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="simplicity_saver.c" /* * Copyright (c) 2001 Marcus L. Reid * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer, * without modification, immediately at the beginning of the file. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* * 20011105 Marcus L. Reid <marcus@punq.net> * * written with much help from fire_saver.c * */ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> #include <sys/module.h> #include <sys/syslog.h> #include <sys/consio.h> #include <sys/fbio.h> #include <dev/fb/fbreg.h> #include <dev/fb/splashreg.h> #include <dev/syscons/syscons.h> #define X_SIZE 320 #define Y_SIZE 200 static int blanked; static u_char k_pal[768]; static u_char buf[X_SIZE * (Y_SIZE + 1)]; static u_char *vid; static int z, cv; static int simplicity_saver(video_adapter_t *adp, int blank) { int x, y; /* Are we supposed to be saving the screen? */ if (blank) { /* Is the screen not in graphics mode? */ if (blanked <= 0) { set_video_mode(adp, M_VGA_CG320); load_palette(adp, k_pal); blanked++; vid = (u_char *) adp->va_window; } /* We're in graphics mode, time for simple magic. */ for (y = 0; y < Y_SIZE; cv += y++) { for (x = 0; x < X_SIZE; cv += x++) { buf[y*X_SIZE+x] = cv % 256; } } cv += z++; /* Done. */ /* blit our buffer into video ram */ memcpy(vid, buf, X_SIZE * Y_SIZE); } else { blanked = 0; } return 0; } static int simplicity_initialise(video_adapter_t *adp) { video_info_t info; int palette_index; /* check that the console is capable of running in 320x200x256 */ if (get_mode_info(adp, M_VGA_CG320, &info)) { log(LOG_NOTICE, "simplicity_saver: the console does not support M_VGA_CG320\n"); return (ENODEV); } /* build palette */ for (palette_index = 0; palette_index < 256; palette_index++) { if(palette_index < 64) { k_pal[(palette_index * 3) + 0] = palette_index * 4; k_pal[(palette_index * 3) + 1] = 0; k_pal[(palette_index * 3) + 2] = 0; } else if(palette_index < 128) { k_pal[(palette_index * 3) + 0] = 0; k_pal[(palette_index * 3) + 1] = (palette_index - 64) * 4; k_pal[(palette_index * 3) + 2] = 0; } else if(palette_index < 192) { k_pal[(palette_index * 3) + 0] = 0; k_pal[(palette_index * 3) + 1] = 0; k_pal[(palette_index * 3) + 2] = (palette_index - 128) * 4; } else if(palette_index < 256) { k_pal[(palette_index * 3) + 0] = (palette_index - 192) * 4; k_pal[(palette_index * 3) + 1] = (palette_index - 192) * 4; k_pal[(palette_index * 3) + 2] = (palette_index - 192) * 4; } } blanked = 0; z = 0; return 0; } static int simplicity_terminate(video_adapter_t *adp) { return 0; } static scrn_saver_t simplicity_module = { "simplicity_saver", simplicity_initialise, simplicity_terminate, simplicity_saver, NULL }; SAVER_MODULE(simplicity_saver, simplicity_module); --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Makefile KMOD= simplicity_saver SRCS= simplicity_saver.c CWARNFLAGS= -Wall -pedantic .include <bsd.kmod.mk> --sdtB3X0nJg68CQEu-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011105191517.A25268>