Deleted Added
full compact
snake_saver.c (10555) snake_saver.c (11857)
1/*-
2 * Copyright (c) 1995 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 * in this position and unchanged.
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 withough 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 *
1/*-
2 * Copyright (c) 1995 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 * in this position and unchanged.
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 withough 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: snake_saver.c,v 1.4 1995/05/30 06:06:18 rgrimes Exp $
28 * $Id: snake_saver.c,v 1.5 1995/09/04 03:02:08 peter Exp $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/conf.h>
34#include <sys/exec.h>
35#include <sys/sysent.h>
36#include <sys/lkm.h>
37#include <sys/errno.h>
38#include <saver.h>
39
40MOD_MISC("snake_saver")
41
42void (*current_saver)();
43void (*old_saver)();
44
45static void
46snake_saver(int blank)
47{
48 const char saves[] = {"FreeBSD-2.2-CURRENT"};
49 static u_char *savs[sizeof(saves)-1];
50 static int dirx, diry;
51 int f;
52 scr_stat *scp = cur_console;
53
54 if (blank) {
55 if (!scrn_blanked) {
56 fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
57 Crtat, scp->xsize * scp->ysize);
58 set_border(0);
59 dirx = (scp->xpos ? 1 : -1);
60 diry = (scp->ypos ?
61 scp->xsize : -scp->xsize);
62 for (f=0; f< sizeof(saves)-1; f++)
63 savs[f] = (u_char *)Crtat + 2 *
64 (scp->xpos+scp->ypos*scp->xsize);
65 *(savs[0]) = scr_map[*saves];
66 f = scp->ysize * scp->xsize + 5;
67 outb(crtc_addr, 14);
68 outb(crtc_addr+1, f >> 8);
69 outb(crtc_addr, 15);
70 outb(crtc_addr+1, f & 0xff);
71 scrn_blanked = 1;
72 }
73 if (scrn_blanked++ < 4)
74 return;
75 scrn_blanked = 1;
76 *(savs[sizeof(saves)-2]) = scr_map[0x20];
77 for (f=sizeof(saves)-2; f > 0; f--)
78 savs[f] = savs[f-1];
79 f = (savs[0] - (u_char *)Crtat) / 2;
80 if ((f % scp->xsize) == 0 ||
81 (f % scp->xsize) == scp->xsize - 1 ||
82 (random() % 50) == 0)
83 dirx = -dirx;
84 if ((f / scp->xsize) == 0 ||
85 (f / scp->xsize) == scp->ysize - 1 ||
86 (random() % 20) == 0)
87 diry = -diry;
88 savs[0] += 2*dirx + 2*diry;
89 for (f=sizeof(saves)-2; f>=0; f--)
90 *(savs[f]) = scr_map[saves[f]];
91 }
92 else {
93 if (scrn_blanked) {
94 set_border(scp->border);
95 scrn_blanked = 0;
96 scp->start = 0;
97 scp->end = scp->xsize * scp->ysize;
98 }
99 }
100}
101
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/conf.h>
34#include <sys/exec.h>
35#include <sys/sysent.h>
36#include <sys/lkm.h>
37#include <sys/errno.h>
38#include <saver.h>
39
40MOD_MISC("snake_saver")
41
42void (*current_saver)();
43void (*old_saver)();
44
45static void
46snake_saver(int blank)
47{
48 const char saves[] = {"FreeBSD-2.2-CURRENT"};
49 static u_char *savs[sizeof(saves)-1];
50 static int dirx, diry;
51 int f;
52 scr_stat *scp = cur_console;
53
54 if (blank) {
55 if (!scrn_blanked) {
56 fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
57 Crtat, scp->xsize * scp->ysize);
58 set_border(0);
59 dirx = (scp->xpos ? 1 : -1);
60 diry = (scp->ypos ?
61 scp->xsize : -scp->xsize);
62 for (f=0; f< sizeof(saves)-1; f++)
63 savs[f] = (u_char *)Crtat + 2 *
64 (scp->xpos+scp->ypos*scp->xsize);
65 *(savs[0]) = scr_map[*saves];
66 f = scp->ysize * scp->xsize + 5;
67 outb(crtc_addr, 14);
68 outb(crtc_addr+1, f >> 8);
69 outb(crtc_addr, 15);
70 outb(crtc_addr+1, f & 0xff);
71 scrn_blanked = 1;
72 }
73 if (scrn_blanked++ < 4)
74 return;
75 scrn_blanked = 1;
76 *(savs[sizeof(saves)-2]) = scr_map[0x20];
77 for (f=sizeof(saves)-2; f > 0; f--)
78 savs[f] = savs[f-1];
79 f = (savs[0] - (u_char *)Crtat) / 2;
80 if ((f % scp->xsize) == 0 ||
81 (f % scp->xsize) == scp->xsize - 1 ||
82 (random() % 50) == 0)
83 dirx = -dirx;
84 if ((f / scp->xsize) == 0 ||
85 (f / scp->xsize) == scp->ysize - 1 ||
86 (random() % 20) == 0)
87 diry = -diry;
88 savs[0] += 2*dirx + 2*diry;
89 for (f=sizeof(saves)-2; f>=0; f--)
90 *(savs[f]) = scr_map[saves[f]];
91 }
92 else {
93 if (scrn_blanked) {
94 set_border(scp->border);
95 scrn_blanked = 0;
96 scp->start = 0;
97 scp->end = scp->xsize * scp->ysize;
98 }
99 }
100}
101
102saver_load(struct lkm_table *lkmtp, int cmd)
102snake_saver_load(struct lkm_table *lkmtp, int cmd)
103{
104 (*current_saver)(0);
105 old_saver = current_saver;
106 current_saver = snake_saver;
107 uprintf("snake screen saver installed\n");
108 return 0;
109}
110
103{
104 (*current_saver)(0);
105 old_saver = current_saver;
106 current_saver = snake_saver;
107 uprintf("snake screen saver installed\n");
108 return 0;
109}
110
111saver_unload(struct lkm_table *lkmtp, int cmd)
111snake_saver_unload(struct lkm_table *lkmtp, int cmd)
112{
113 (*current_saver)(0);
114 current_saver = old_saver;
115 uprintf("snake screen saver removed\n");
116 return 0;
117}
118
112{
113 (*current_saver)(0);
114 current_saver = old_saver;
115 uprintf("snake screen saver removed\n");
116 return 0;
117}
118
119saver_init(struct lkm_table *lkmtp, int cmd, int ver)
119snake_saver_mod(struct lkm_table *lkmtp, int cmd, int ver)
120{
120{
121 DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
121 DISPATCH(lkmtp, cmd, ver, snake_saver_load, snake_saver_unload, nosys);
122}
122}