1 /* $NetBSD: palette.c,v 1.6 2006/08/04 02:30:00 mhitch Exp $ */
3 * pelette - manipulate text colormap for NetBSD/x68k.
6 * This software is in the Public Domain.
10 __RCSID("$NetBSD: palette.c,v 1.6 2006/08/04 02:30:00 mhitch Exp $");
14 #include <sys/param.h>
15 #include <sys/ioctl.h>
17 #include <sys/fcntl.h>
19 #define PALETTE_OFFSET 0x2000 /* physical addr: 0xe82000 */
20 #define PALETTE_SIZE 0x1000 /* at least 1 page */
23 main(int argc
, char *argv
[])
34 printf("argc = %d\n", argc
);
35 for (i
= 0; i
< argc
; i
++)
36 printf("argv[%d] = \"%s\"\n", i
, argv
[i
]);
40 if ((fd
= open("/dev/grf0", O_RDWR
, 0)) < 0) {
45 mapaddr
= mmap(0, PALETTE_SIZE
, PROT_READ
| PROT_WRITE
,
46 MAP_FILE
| MAP_SHARED
, fd
, PALETTE_OFFSET
);
47 if (mapaddr
== (void *)-1) {
53 palette
= (u_short
*)(mapaddr
+ 0x0200);
56 c
= atoi(argv
[--argc
]);
58 printf("Usage: %s [red green blue [code]]\n", argv
[0]);
68 if (r
> 31 || g
> 31 || b
> 31) {
69 printf("Usage: %s [red green blue [code]]\n", argv
[0]);
74 printf("color table offset = %d\n", c
);
75 printf("r = %d, g = %d, b = %d\n", r
, g
, b
);
81 palette
[c
] = r
| g
| b
| 1;