2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer
12 * in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
37 #include <sys/syslog.h>
38 #include <sys/consio.h>
41 #include <dev/fb/fbreg.h>
42 #include <dev/fb/splashreg.h>
43 #include <dev/syscons/syscons.h>
45 #define SAVER_NAME "warp_saver"
47 #define STARS (SPP * (1 + 2 + 4 + 8))
49 #define SET_ORIGIN(adp, o) do { \
51 if (oo != last_origin) \
52 vidd_set_win_org(adp, last_origin = oo); \
56 static int banksize, scrmode, bpsl, scrw, scrh;
58 static int star[STARS];
59 static u_char warp_pal[768] = {
65 /* the rest is zero-filled by the compiler */
69 warp_update(video_adapter_t *adp)
74 for (i = 1, k = 0, n = SPP*8; i < 5; i++, n /= 2) {
75 for (j = 0; j < n; j++, k++) {
76 p = (star[k] / scrw) * bpsl + (star[k] % scrw);
78 while (p > banksize) {
85 if (star[k] > scrw*scrh)
87 p = (star[k] / scrw) * bpsl + (star[k] % scrw);
89 while (p > banksize) {
100 warp_saver(video_adapter_t *adp, int blank)
105 /* switch to graphics mode */
108 vidd_set_mode(adp, scrmode);
109 vidd_load_palette(adp, warp_pal);
110 vidd_set_border(adp, 0);
112 vid = (u_char *)adp->va_window;
113 banksize = adp->va_window_size;
114 bpsl = adp->va_line_width;
127 warp_init(video_adapter_t *adp)
132 if (!vidd_get_info(adp, M_VGA_CG320, &info)) {
133 scrmode = M_VGA_CG320;
136 "%s: the console does not support M_VGA_CG320\n",
141 scrw = info.vi_width;
142 scrh = info.vi_height;
144 /* randomize the star field */
145 for (i = 0; i < STARS; i++)
146 star[i] = random() % (scrw * scrh);
152 warp_term(video_adapter_t *adp)
157 static scrn_saver_t warp_module = {
165 SAVER_MODULE(warp_saver, warp_module);