summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2005-04-25 00:28:13 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2005-04-25 00:28:13 +0000
commitf7db23bdb08311aa046b8d79045af1ddda046fc2 (patch)
tree011c29244d0b80cb673e7a55f546b4845ab60f37 /usr.sbin
parentd2c4493bbc3f194ba49a43d545e08ab962422706 (diff)
- display a message centered on the screen
- undo a signal handler change which slipped in with the previous commit
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ztsscale/message.xbm38
-rw-r--r--usr.sbin/ztsscale/ztsscale.c45
2 files changed, 71 insertions, 12 deletions
diff --git a/usr.sbin/ztsscale/message.xbm b/usr.sbin/ztsscale/message.xbm
new file mode 100644
index 00000000000..288bee60974
--- /dev/null
+++ b/usr.sbin/ztsscale/message.xbm
@@ -0,0 +1,38 @@
+#define message_width 280
+#define message_height 12
+static unsigned char message_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xec, 0x78,
+ 0xf8, 0xf0, 0x00, 0xf0, 0xf8, 0x01, 0xf0, 0xe3, 0xc3, 0x03, 0x80, 0xc7,
+ 0x8e, 0x07, 0x0f, 0x1f, 0x00, 0x1f, 0x1f, 0x0e, 0x76, 0x7c, 0x00, 0x77,
+ 0x30, 0x78, 0x78, 0xf0, 0xf1, 0x00, 0x00, 0x00, 0x44, 0x5c, 0xcc, 0xc8,
+ 0xd8, 0x00, 0x98, 0x31, 0x01, 0x60, 0x60, 0x62, 0x06, 0xc0, 0x86, 0xcb,
+ 0x8c, 0x8d, 0x09, 0x00, 0x13, 0x19, 0x0a, 0x2e, 0x26, 0x00, 0xce, 0x10,
+ 0xcc, 0xc8, 0x98, 0x98, 0x01, 0x00, 0x00, 0x7c, 0x08, 0x94, 0x18, 0x18,
+ 0x00, 0x18, 0x13, 0x01, 0x60, 0x60, 0xa4, 0x04, 0x20, 0x0c, 0xc1, 0x98,
+ 0x81, 0x03, 0x00, 0x13, 0x10, 0x08, 0x04, 0x0e, 0x00, 0x84, 0x30, 0x94,
+ 0xd1, 0x30, 0x28, 0x03, 0x00, 0x00, 0x06, 0x08, 0xee, 0xf4, 0xe8, 0x01,
+ 0x08, 0x12, 0x01, 0x20, 0x20, 0x72, 0x07, 0x20, 0x80, 0x40, 0x90, 0x1e,
+ 0x1d, 0x00, 0x11, 0x1f, 0x0c, 0x04, 0x74, 0x00, 0x84, 0x10, 0xee, 0xd8,
+ 0xe8, 0xdd, 0x02, 0x00, 0x00, 0x04, 0x08, 0x0c, 0x8c, 0x89, 0x01, 0x18,
+ 0x13, 0x01, 0x60, 0x22, 0x62, 0x00, 0x60, 0x84, 0xc0, 0x98, 0x98, 0x11,
+ 0x00, 0x31, 0x31, 0x08, 0x04, 0x46, 0x00, 0xc4, 0x30, 0x0c, 0x88, 0x08,
+ 0x19, 0x00, 0x00, 0x00, 0x1f, 0x7e, 0xfc, 0xfd, 0xf8, 0x00, 0xf0, 0xb9,
+ 0x03, 0xc0, 0x73, 0xe7, 0x0f, 0xc0, 0xc7, 0x87, 0x8f, 0x8f, 0x1f, 0x80,
+ 0x3b, 0x3f, 0x7f, 0x3f, 0x7e, 0x00, 0x7e, 0xfc, 0xf8, 0xfd, 0xf9, 0xf1,
+ 0x63, 0xc0, 0xc0, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x80, 0x00, 0x04, 0x00, 0x80, 0x80, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x10, 0x08, 0x08, 0x00, 0x00, 0x04, 0x80, 0x20, 0x10, 0x00, 0x40, 0x40,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/usr.sbin/ztsscale/ztsscale.c b/usr.sbin/ztsscale/ztsscale.c
index fb8627b138e..4ba13752853 100644
--- a/usr.sbin/ztsscale/ztsscale.c
+++ b/usr.sbin/ztsscale/ztsscale.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ztsscale.c,v 1.4 2005/04/24 23:43:15 uwe Exp $ */
+/* $OpenBSD: ztsscale.c,v 1.5 2005/04/25 00:28:12 uwe Exp $ */
/*
* Copyright (c) 2005 Matthieu Herrb
@@ -32,6 +32,8 @@
#include <string.h>
#include <unistd.h>
+#include "message.xbm"
+
#define WIDTH 640
#define HEIGHT 480
#define BLACK 0x0
@@ -39,15 +41,16 @@
#define ADDR(x,y) (HEIGHT*(x)+(y))
-unsigned short *mapaddr, *save;
-int fd;
-int xc[] = { 25, 25, 320, 615, 615 };
-int yc[] = { 25, 455, 240, 25, 455 };
+u_short *mapaddr, *save;
+int fd;
+int xc[] = { 25, 25, 320, 615, 615 };
+int yc[] = { 25, 455, 240, 25, 455 };
struct ctlname topname[] = CTL_NAMES;
struct ctlname machdepname[] = CTL_MACHDEP_NAMES;
-void cross(unsigned short *, int, int);
+void bitmap(u_short *, u_short, u_char[], int, int);
+void cross(u_short *, int, int);
void wait_event(int, int *, int *);
void save_screen(void);
void restore_screen(void);
@@ -56,7 +59,22 @@ int main(int, char *[]);
__dead void usage(void);
void
-cross(unsigned short *fb, int x, int y)
+bitmap(u_short *fb, u_short color, u_char bits[], int width, int height)
+{
+ int i, j;
+ int x, y;
+
+ for (i = 0; i < height; i++) {
+ x = (WIDTH - width) / 2;
+ y = HEIGHT + (HEIGHT - height)/2 + 60;
+ for (j = 0; j < width; j++)
+ if (bits[((i * width) + j) / 8] & (1 << (j % 8)))
+ fb[ADDR(x + j, y - i - 1)] = BLACK;
+ }
+}
+
+void
+cross(u_short *fb, int x, int y)
{
int i;
@@ -119,10 +137,10 @@ save_screen(void)
PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (mapaddr == (void *)-1)
err(2, "mmap");
- save = (unsigned short *)malloc(WIDTH*HEIGHT*sizeof(unsigned short));
+ save = (u_short *)malloc(WIDTH*HEIGHT*sizeof(u_short));
if (save == NULL)
err(2, "malloc");
- memcpy(save, mapaddr, WIDTH*HEIGHT*sizeof(unsigned short));
+ memcpy(save, mapaddr, WIDTH*HEIGHT*sizeof(u_short));
}
void
@@ -130,7 +148,7 @@ restore_screen(void)
{
int mode = WSDISPLAYIO_MODE_EMUL;
- memcpy(mapaddr, save, WIDTH*HEIGHT*sizeof(unsigned short));
+ memcpy(mapaddr, save, WIDTH*HEIGHT*sizeof(u_short));
if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) == -1)
warn("ioctl SMODE");
}
@@ -139,7 +157,8 @@ void
sighandler(int sig)
{
restore_screen();
- _exit(128 + sig);
+ close(fd);
+ _exit(2);
}
int
@@ -182,7 +201,9 @@ again:
save_screen();
signal(SIGINT, sighandler);
for (i = 0; i < 5; i++) {
- memset(mapaddr, WHITE, WIDTH*HEIGHT*sizeof(unsigned short));
+ memset(mapaddr, WHITE, WIDTH*HEIGHT*sizeof(u_short));
+ bitmap(mapaddr, BLACK, message_bits, message_width,
+ message_height);
cross(mapaddr, xc[i], yc[i]);
/* printf("waiting for event\n"); */
wait_event(mfd, &x[i], &y[i]);