summaryrefslogtreecommitdiffstats
path: root/lkm
diff options
context:
space:
mode:
Diffstat (limited to 'lkm')
-rw-r--r--lkm/Makefile4
-rw-r--r--lkm/syscons/Makefile5
-rw-r--r--lkm/syscons/blank/Makefile10
-rw-r--r--lkm/syscons/blank/blank_saver.c81
-rw-r--r--lkm/syscons/fade/Makefile10
-rw-r--r--lkm/syscons/fade/fade_saver.c96
-rw-r--r--lkm/syscons/green/Makefile10
-rw-r--r--lkm/syscons/green/green_saver.c85
-rw-r--r--lkm/syscons/saver.h16
-rw-r--r--lkm/syscons/snake/Makefile10
-rw-r--r--lkm/syscons/snake/snake_saver.c121
-rw-r--r--lkm/syscons/star/Makefile10
-rw-r--r--lkm/syscons/star/star_saver.c111
13 files changed, 567 insertions, 2 deletions
diff --git a/lkm/Makefile b/lkm/Makefile
index 3d98fa7..e6f2d66 100644
--- a/lkm/Makefile
+++ b/lkm/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.6 1994/10/16 20:39:52 sos Exp $
+# $Id: Makefile,v 1.7 1995/01/30 14:21:46 ugen Exp $
SUBDIR= cd9660 coff fdesc ibcs2 ip_mroute_mod ipfw kernfs msdos nfs nullfs \
- portal procfs socksys umapfs union
+ portal procfs socksys syscons umapfs union
#
# Doesn't work:
# mfs
diff --git a/lkm/syscons/Makefile b/lkm/syscons/Makefile
new file mode 100644
index 0000000..edd608e
--- /dev/null
+++ b/lkm/syscons/Makefile
@@ -0,0 +1,5 @@
+# $Id$
+
+SUBDIR= blank fade green snake star
+
+.include <bsd.subdir.mk>
diff --git a/lkm/syscons/blank/Makefile b/lkm/syscons/blank/Makefile
new file mode 100644
index 0000000..c920cf4
--- /dev/null
+++ b/lkm/syscons/blank/Makefile
@@ -0,0 +1,10 @@
+# $Id$
+
+BINDIR= ${DESTDIR}/lkm
+KMOD= blank_saver_mod
+SRCS= blank_saver.c
+
+NOMAN=
+CFLAGS+= -DLKM -I${.CURDIR}/.. -I${.CURDIR}/../../../sys
+
+.include <bsd.kmod.mk>
diff --git a/lkm/syscons/blank/blank_saver.c b/lkm/syscons/blank/blank_saver.c
new file mode 100644
index 0000000..9362c0b
--- /dev/null
+++ b/lkm/syscons/blank/blank_saver.c
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 1995 Søren Schmidt
+ * 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
+ * in this position and unchanged.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/sysent.h>
+#include <sys/lkm.h>
+#include <sys/errno.h>
+#include <saver.h>
+
+MOD_MISC("blank_saver")
+
+void (*current_saver)();
+void (*old_saver)();
+
+static void
+blank_saver(int blank)
+{
+ u_char val;
+ if (blank) {
+ scrn_blanked = 1;
+ outb(TSIDX, 0x01); val = inb(TSREG);
+ outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
+ }
+ else {
+ outb(TSIDX, 0x01); val = inb(TSREG);
+ outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
+ scrn_blanked = 0;
+ }
+}
+
+saver_load(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ old_saver = current_saver;
+ current_saver = blank_saver;
+ uprintf("blank screen saver installed\n");
+ return 0;
+}
+
+saver_unload(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ current_saver = old_saver;
+ uprintf("blank screen saver removed\n");
+ return 0;
+}
+
+saver_init(struct lkm_table *lkmtp, int cmd, int ver)
+{
+ DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
+}
diff --git a/lkm/syscons/fade/Makefile b/lkm/syscons/fade/Makefile
new file mode 100644
index 0000000..610a195
--- /dev/null
+++ b/lkm/syscons/fade/Makefile
@@ -0,0 +1,10 @@
+# $Id$
+
+BINDIR= ${DESTDIR}/lkm
+KMOD= fade_saver_mod
+SRCS= fade_saver.c
+
+NOMAN=
+CFLAGS+= -DLKM -I${.CURDIR}/.. -I${.CURDIR}/../../../sys
+
+.include <bsd.kmod.mk>
diff --git a/lkm/syscons/fade/fade_saver.c b/lkm/syscons/fade/fade_saver.c
new file mode 100644
index 0000000..a58eaa0
--- /dev/null
+++ b/lkm/syscons/fade/fade_saver.c
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 1995 Søren Schmidt
+ * 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
+ * in this position and unchanged.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/sysent.h>
+#include <sys/lkm.h>
+#include <sys/errno.h>
+#include <saver.h>
+
+MOD_MISC("fade_saver")
+
+void (*current_saver)();
+void (*old_saver)();
+
+static void
+fade_saver(int blank)
+{
+ static int count = 0;
+ int i;
+
+ if (blank) {
+ scrn_blanked = 1;
+ if (count < 64) {
+ outb(PIXMASK, 0xFF); /* no pixelmask */
+ outb(PALWADR, 0x00);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ for (i = 3; i < 768; i++) {
+ if (palette[i] - count > 15)
+ outb(PALDATA, palette[i]-count);
+ else
+ outb(PALDATA, 15);
+ }
+ inb(crtc_addr+6); /* reset flip/flop */
+ outb(ATC, 0x20); /* enable palette */
+ count++;
+ }
+ }
+ else {
+ load_palette();
+ count = scrn_blanked = 0;
+ }
+}
+
+saver_load(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ old_saver = current_saver;
+ current_saver = fade_saver;
+ uprintf("fade screen saver installed\n");
+ return 0;
+}
+
+saver_unload(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ current_saver = old_saver;
+ uprintf("fade screen saver removed\n");
+ return 0;
+}
+
+saver_init(struct lkm_table *lkmtp, int cmd, int ver)
+{
+ DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
+}
diff --git a/lkm/syscons/green/Makefile b/lkm/syscons/green/Makefile
new file mode 100644
index 0000000..9c1ae14
--- /dev/null
+++ b/lkm/syscons/green/Makefile
@@ -0,0 +1,10 @@
+# $Id$
+
+BINDIR= ${DESTDIR}/lkm
+KMOD= green_saver_mod
+SRCS= green_saver.c
+
+NOMAN=
+CFLAGS+= -DLKM -I${.CURDIR}/.. -I${.CURDIR}/../../../sys
+
+.include <bsd.kmod.mk>
diff --git a/lkm/syscons/green/green_saver.c b/lkm/syscons/green/green_saver.c
new file mode 100644
index 0000000..e6ed074
--- /dev/null
+++ b/lkm/syscons/green/green_saver.c
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 1995 Søren Schmidt
+ * 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
+ * in this position and unchanged.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/sysent.h>
+#include <sys/lkm.h>
+#include <sys/errno.h>
+#include <saver.h>
+
+MOD_MISC("green_saver")
+
+void (*current_saver)();
+void (*old_saver)();
+
+static void
+green_saver(int blank)
+{
+ u_char val;
+ if (blank) {
+ scrn_blanked = 1;
+ outb(TSIDX, 0x01); val = inb(TSREG);
+ outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
+ outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
+ outb(crtc_addr + 1, val & ~0x80);
+ }
+ else {
+ outb(TSIDX, 0x01); val = inb(TSREG);
+ outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
+ outb(crtc_addr, 0x17); val = inb(crtc_addr + 1);
+ outb(crtc_addr + 1, val | 0x80);
+ scrn_blanked = 0;
+ }
+}
+
+saver_load(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ old_saver = current_saver;
+ current_saver = green_saver;
+ uprintf("green screen saver installed\n");
+ return 0;
+}
+
+saver_unload(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ current_saver = old_saver;
+ uprintf("green screen saver removed\n");
+ return 0;
+}
+
+saver_init(struct lkm_table *lkmtp, int cmd, int ver)
+{
+ DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
+}
diff --git a/lkm/syscons/saver.h b/lkm/syscons/saver.h
new file mode 100644
index 0000000..a51c72c
--- /dev/null
+++ b/lkm/syscons/saver.h
@@ -0,0 +1,16 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/tty.h>
+#include <i386/include/pc/display.h>
+#include <i386/include/console.h>
+#include <i386/i386/cons.h>
+#include <i386/isa/isa.h>
+#include <i386/isa/isa_device.h>
+#include <i386/isa/syscons.h>
+
+extern scr_stat *cur_console;
+extern u_short *Crtat;
+extern u_int crtc_addr;
+extern char scr_map[];
+extern int scrn_blanked;
+extern char *palette;
diff --git a/lkm/syscons/snake/Makefile b/lkm/syscons/snake/Makefile
new file mode 100644
index 0000000..bc8b2b2
--- /dev/null
+++ b/lkm/syscons/snake/Makefile
@@ -0,0 +1,10 @@
+# $Id$
+
+BINDIR= ${DESTDIR}/lkm
+KMOD= snake_saver_mod
+SRCS= snake_saver.c
+
+NOMAN=
+CFLAGS+= -DLKM -I${.CURDIR}/.. -I${.CURDIR}/../../../sys
+
+.include <bsd.kmod.mk>
diff --git a/lkm/syscons/snake/snake_saver.c b/lkm/syscons/snake/snake_saver.c
new file mode 100644
index 0000000..1974980
--- /dev/null
+++ b/lkm/syscons/snake/snake_saver.c
@@ -0,0 +1,121 @@
+/*-
+ * Copyright (c) 1995 Søren Schmidt
+ * 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
+ * in this position and unchanged.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/sysent.h>
+#include <sys/lkm.h>
+#include <sys/errno.h>
+#include <saver.h>
+
+MOD_MISC("snake_saver")
+
+void (*current_saver)();
+void (*old_saver)();
+
+static void
+snake_saver(int blank)
+{
+ const char saves[] = {"FreeBSD-2.1"};
+ static u_char *savs[sizeof(saves)-1];
+ static int dirx, diry;
+ int f;
+ scr_stat *scp = cur_console;
+
+ if (blank) {
+ if (!scrn_blanked) {
+ fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
+ Crtat, scp->xsize * scp->ysize);
+ set_border(0);
+ dirx = (scp->xpos ? 1 : -1);
+ diry = (scp->ypos ?
+ scp->xsize : -scp->xsize);
+ for (f=0; f< sizeof(saves)-1; f++)
+ savs[f] = (u_char *)Crtat + 2 *
+ (scp->xpos+scp->ypos*scp->xsize);
+ *(savs[0]) = scr_map[*saves];
+ f = scp->ysize * scp->xsize + 5;
+ outb(crtc_addr, 14);
+ outb(crtc_addr+1, f >> 8);
+ outb(crtc_addr, 15);
+ outb(crtc_addr+1, f & 0xff);
+ scrn_blanked = 1;
+ }
+ if (scrn_blanked++ < 4)
+ return;
+ scrn_blanked = 1;
+ *(savs[sizeof(saves)-2]) = scr_map[0x20];
+ for (f=sizeof(saves)-2; f > 0; f--)
+ savs[f] = savs[f-1];
+ f = (savs[0] - (u_char *)Crtat) / 2;
+ if ((f % scp->xsize) == 0 ||
+ (f % scp->xsize) == scp->xsize - 1 ||
+ (random() % 50) == 0)
+ dirx = -dirx;
+ if ((f / scp->xsize) == 0 ||
+ (f / scp->xsize) == scp->ysize - 1 ||
+ (random() % 20) == 0)
+ diry = -diry;
+ savs[0] += 2*dirx + 2*diry;
+ for (f=sizeof(saves)-2; f>=0; f--)
+ *(savs[f]) = scr_map[saves[f]];
+ }
+ else {
+ if (scrn_blanked) {
+ set_border(scp->border);
+ scrn_blanked = 0;
+ scp->status |= UPDATE_SCREEN;
+ }
+ }
+}
+
+saver_load(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ old_saver = current_saver;
+ current_saver = snake_saver;
+ uprintf("snake screen saver installed\n");
+ return 0;
+}
+
+saver_unload(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ current_saver = old_saver;
+ uprintf("snake screen saver removed\n");
+ return 0;
+}
+
+saver_init(struct lkm_table *lkmtp, int cmd, int ver)
+{
+ DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
+}
diff --git a/lkm/syscons/star/Makefile b/lkm/syscons/star/Makefile
new file mode 100644
index 0000000..fc2ae17
--- /dev/null
+++ b/lkm/syscons/star/Makefile
@@ -0,0 +1,10 @@
+# $Id$
+
+BINDIR= ${DESTDIR}/lkm
+KMOD= star_saver_mod
+SRCS= star_saver.c
+
+NOMAN=
+CFLAGS+= -DLKM -I${.CURDIR}/.. -I${.CURDIR}/../../../sys
+
+.include <bsd.kmod.mk>
diff --git a/lkm/syscons/star/star_saver.c b/lkm/syscons/star/star_saver.c
new file mode 100644
index 0000000..f18dc09
--- /dev/null
+++ b/lkm/syscons/star/star_saver.c
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 1995 Søren Schmidt
+ * 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
+ * in this position and unchanged.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/sysent.h>
+#include <sys/lkm.h>
+#include <sys/errno.h>
+#include <saver.h>
+
+MOD_MISC("star_saver")
+
+void (*current_saver)();
+void (*old_saver)();
+
+#define NUM_STARS 50
+
+/*
+ * Alternate saver that got its inspiration from a well known utility
+ * package for an inferior^H^H^H^H^H^Hfamous OS.
+ */
+void
+star_saver(int blank)
+{
+ scr_stat *scp = cur_console;
+ int cell, i;
+ char pattern[] = {"...........++++*** "};
+ char colors[] = {FG_DARKGREY, FG_LIGHTGREY,
+ FG_WHITE, FG_LIGHTCYAN};
+ static u_short stars[NUM_STARS][2];
+
+ if (blank) {
+ if (!scrn_blanked) {
+ scrn_blanked = 1;
+ fillw((FG_LIGHTGREY|BG_BLACK)<<8|scr_map[0x20], Crtat,
+ scp->xsize * scp->ysize);
+ set_border(0);
+ for(i=0; i<NUM_STARS; i++) {
+ stars[i][0] =
+ random() % (scp->xsize*scp->ysize);
+ stars[i][1] = 0;
+ }
+ }
+ cell = random() % NUM_STARS;
+ *((u_short*)(Crtat + stars[cell][0])) =
+ scr_map[pattern[stars[cell][1]]] |
+ colors[random()%sizeof(colors)] << 8;
+ if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) {
+ stars[cell][0] = random() % (scp->xsize*scp->ysize);
+ stars[cell][1] = 0;
+ }
+ }
+ else {
+ if (scrn_blanked) {
+ set_border(scp->border);
+ scrn_blanked = 0;
+ scp->status |= UPDATE_SCREEN;
+ }
+ }
+}
+
+saver_load(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ old_saver = current_saver;
+ current_saver = star_saver;
+ uprintf("star screen saver installed\n");
+ return 0;
+}
+
+saver_unload(struct lkm_table *lkmtp, int cmd)
+{
+ (*current_saver)(0);
+ current_saver = old_saver;
+ uprintf("star screen saver removed\n");
+ return 0;
+}
+
+saver_init(struct lkm_table *lkmtp, int cmd, int ver)
+{
+ DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
+}
OpenPOWER on IntegriCloud