Remove x68k/stand/bootlogo/ directory.
It was a tool before the bootloader becomes multi-stage (>10 years ago), and it does not work anymore today.
This commit is contained in:
parent
2eb9e5d971
commit
411606c690
@ -1,5 +0,0 @@
|
||||
# $NetBSD: MANIFEST,v 1.1 2002/01/27 01:47:59 minoura Exp $
|
||||
|
||||
netbsd.xpm Default boot image. The BSD Daemon is used by permission.
|
||||
xpm2bootimg.c Convert *.xpm to boot title image format.
|
||||
setbootimg.c Change boot title image of specified boot block (or file).
|
@ -1,80 +0,0 @@
|
||||
/* XPM */
|
||||
static char *netbsd[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
"56 52 5 1 XPMEXT",
|
||||
/* colors */
|
||||
" c None",
|
||||
"# c #000000",
|
||||
"* c #555555",
|
||||
"+ c #aaaaaa",
|
||||
". c #ffffff",
|
||||
/* pixels */
|
||||
" +. + ",
|
||||
" *.. . ",
|
||||
" *..+ ++ ",
|
||||
" +..* +.* ",
|
||||
" *..+** *++* ",
|
||||
" +.+**.+** ++++ *.+** ",
|
||||
" ..+**##*.*+++++++ *.+** ",
|
||||
" ..**++##.+++##**** *...+** ",
|
||||
" *..+##.#..##..##*****...++** ",
|
||||
" *+#..#..#..##.##++.....++** ",
|
||||
" +#...#.##....#.#*+.....++*# ",
|
||||
" #....#.#.....#....+...++**# ",
|
||||
" +#....#.#......#.+++++++**# ",
|
||||
" #..##.#.###....#..++*****# ",
|
||||
" #.####.#####...#...+++**# ",
|
||||
" +#.#.##.##.##...#...++++* ",
|
||||
" .#.#+##.##.##...#....+++** ",
|
||||
" . +.*###########..#.....+++** ",
|
||||
" .+ ...*###...###..#*.....+++*# ",
|
||||
" + +.....#.....####*+++...+++*# ",
|
||||
" .. ++ +.....#....#*.........+++** ",
|
||||
" . + +.##..####**.........+++*# ",
|
||||
" + . +..##........#####.+++** ",
|
||||
".+ +.. *.++#.....###++..+++**# ",
|
||||
" . ++. *+++######++...+++**# ",
|
||||
" + .+*+. *++++++++...+*****# ",
|
||||
" +++ +*++.*# *+++*...+++++**# ",
|
||||
" **...* *.........++** ",
|
||||
" +..*.*#* +...........++** ",
|
||||
" ...*##+** ++............+*** ",
|
||||
" *.+*#*+++*#..####....+..++*** ",
|
||||
" ####++*++##+..+########++** ",
|
||||
" .... ....#**+**.....#.......##** ..... ........+ ",
|
||||
" +.. #.#**++***.....#..###...## .. ... .. ... ",
|
||||
" .... ..#*********####..#.+#..##.. . .. .. ",
|
||||
" .... ..#*########.###..#++#..# .. . .. ...",
|
||||
" +..... . ######..##...#+#...# ... ... ...",
|
||||
" +. ... .. ...##.....#..###...## .... .. ...",
|
||||
" .. .. .. .. #..##..###......##### .... .. ...",
|
||||
" .. ... .. .. #..##..###..###..#***# .... .. .. ",
|
||||
" +.. .... .. ..##...##...#+*#..##++# ... ... ... ",
|
||||
" .. .... .... ##..###...#++#..#.#+++#.. .. ..+ ",
|
||||
" .. ... .. .#..###..####...#.###.#..#.. .... ",
|
||||
" .. .. ... . #..#.#..###...# ...##..##..# .... ",
|
||||
".... . .... ##..#........## ......##.......##** ",
|
||||
" ######+++###########*** ##+*#######+.++* ",
|
||||
" ......+..######+++++++++*# #..#***.....+*",
|
||||
" +.....+++#.....+...++++**** *+...# ####.++",
|
||||
" +++++++#+....++++++++++*** *++....+++++++.+++",
|
||||
" ****#*+#+++++++***++***# +.+....+***+++++++*",
|
||||
" ##********# #**#*++###****#*#",
|
||||
" ##*+# ### ",
|
||||
"XPMEXT copyright",
|
||||
"BSD Daemon Copyright 1988 by Marshall Kirk McKusick."
|
||||
"XPMEXT copyright_long",
|
||||
"BSD Daemon image, used for NetBSD boot by permission.",
|
||||
"",
|
||||
"BSD Daemon Copyright 1988 by Marshall Kirk McKusick.",
|
||||
"All Rights Reserved.",
|
||||
"",
|
||||
"Permission to use the daemon may be obtained from:",
|
||||
" Marshall Kirk McKusick",
|
||||
" 1614 Oxford St",
|
||||
" Berkeley, CA 94709-1608",
|
||||
" USA",
|
||||
"or via email at mckusick@mckusick.com",
|
||||
"XPMEXT rcsid $NetBSD: netbsd.xpm,v 1.1 2002/01/27 01:47:59 minoura Exp $",
|
||||
"XPMENDEXT"
|
||||
};
|
@ -1,237 +0,0 @@
|
||||
/* $NetBSD: setbootimg.c,v 1.4 2011/02/21 02:31:58 itohy Exp $ */
|
||||
|
||||
/*
|
||||
* set boot title image (converted by xpm2bootimg)
|
||||
* to boot file or installed boot block
|
||||
*
|
||||
* use with care, not to destroy the existent boot or the disklabel
|
||||
*
|
||||
* written by ITOH Yasufumi, public domain
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef __NetBSD__
|
||||
#include <err.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* define here for cross env
|
||||
*/
|
||||
#define SIZE_BOOTBLK 8192 /* <ufs/ffs/fs.h> BBSIZE */
|
||||
#define MAGIC_DISKLABEL 0x82564557 /* <sys/disklabel.h> DISKMAGIC */
|
||||
#define X68K_LABELOFF 64 /* <x68k/disklabel.h> LABELOFFSET */
|
||||
|
||||
#ifdef __STDC__
|
||||
# define PROTO(x) x
|
||||
#else
|
||||
# define PROTO(x) ()
|
||||
# ifndef const
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main PROTO((int argc, char *argv[]));
|
||||
static unsigned get_uint16 PROTO((void *));
|
||||
static unsigned get_uint32 PROTO((void *));
|
||||
|
||||
#ifndef __NetBSD__
|
||||
/* for cross env */
|
||||
|
||||
#ifdef __STDC__
|
||||
# include <stdarg.h>
|
||||
# define VA_START(a, v) va_start(a, v)
|
||||
# include <errno.h>
|
||||
#else
|
||||
# include <varargs.h>
|
||||
# define VA_START(a, v) va_start(a)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static void err PROTO((int eval, const char *fmt, ...));
|
||||
static void errx PROTO((int eval, const char *fmt, ...));
|
||||
|
||||
static void
|
||||
#ifdef __STDC__
|
||||
err(int eval, const char *fmt, ...)
|
||||
#else
|
||||
err(eval, fmt, va_alist)
|
||||
int eval;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int e = errno;
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "setbootimg: ");
|
||||
if (fmt) {
|
||||
VA_START(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fprintf(stderr, ": ");
|
||||
}
|
||||
errno = e;
|
||||
perror((char *) 0);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
static void
|
||||
#ifdef __STDC__
|
||||
errx(int eval, const char *fmt, ...)
|
||||
#else
|
||||
errx(eval, fmt, va_alist)
|
||||
int eval;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "setbootimg: ");
|
||||
if (fmt) {
|
||||
VA_START(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static unsigned
|
||||
get_uint16(void *p)
|
||||
{
|
||||
unsigned char *q = p;
|
||||
|
||||
return q[0] << 8 | q[1];
|
||||
}
|
||||
|
||||
static unsigned
|
||||
get_uint32(void *p)
|
||||
{
|
||||
unsigned char *q = p;
|
||||
|
||||
return q[0] << 24 | q[1] << 16 | q[2] << 8 | q[3];
|
||||
}
|
||||
|
||||
|
||||
static const char boottop[] = {
|
||||
0x60, 0x24, 0x53, 0x48, 0x41, 0x52, 0x50, 0x2F,
|
||||
0x58, 0x36, 0x38, 0x30, 0x78, 0x30, 0x81, 0x99,
|
||||
0x94, 0xE6, 0x82, 0xEA, 0x82, 0xBD, 0x8E, 0x9E,
|
||||
0x82, 0xC9, 0x82, 0xCD, 0x8C, 0xBB, 0x8E, 0xC0,
|
||||
0x93, 0xA6, 0x94, 0xF0, 0x81, 0x49
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *imgfile, *bootfile;
|
||||
char img[SIZE_BOOTBLK], boot[SIZE_BOOTBLK];
|
||||
int size_img, size_boot;
|
||||
int fd;
|
||||
int labelstart, labelend, imgstart, imgend;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "usage: %s image_file boot_block\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
imgfile = argv[1];
|
||||
bootfile = argv[2];
|
||||
|
||||
/*
|
||||
* read image
|
||||
*/
|
||||
if ((fd = open(imgfile, O_RDONLY)) < 0)
|
||||
err(1, "%s", imgfile);
|
||||
|
||||
if ((size_img = read(fd, img, sizeof img)) < 0)
|
||||
err(1, "%s", imgfile);
|
||||
|
||||
if (size_img >= (int) sizeof img)
|
||||
errx(1, "%s: file too large", imgfile);
|
||||
|
||||
(void) close(fd);
|
||||
|
||||
/*
|
||||
* read boot block
|
||||
*/
|
||||
if ((fd = open(bootfile, O_RDWR)) < 0)
|
||||
err(1, "%s", bootfile);
|
||||
|
||||
if ((size_boot = read(fd, boot, sizeof boot)) < 0)
|
||||
err(1, "%s", bootfile);
|
||||
|
||||
if (lseek(fd, (off_t) 0, SEEK_SET))
|
||||
err(1, "%s: lseek", bootfile);
|
||||
|
||||
if (size_boot < 4096) /* XXX */
|
||||
errx(1, "%s: too short", bootfile);
|
||||
|
||||
/*
|
||||
* check boot block
|
||||
*/
|
||||
if (memcmp(boot, boottop, sizeof boottop))
|
||||
errx(1, "%s: not a boot", bootfile);
|
||||
|
||||
labelstart = X68K_LABELOFF;
|
||||
if (get_uint16(boot + labelstart - 4) != 0x6000) /* bra */
|
||||
badboot: errx(1, "%s: wrong boot block", bootfile);
|
||||
|
||||
labelend = labelstart + get_uint16(boot + labelstart - 2) - 4;
|
||||
if (labelend >= size_boot)
|
||||
goto badboot;
|
||||
|
||||
imgstart = get_uint16(boot + labelend);
|
||||
if (imgstart == 0)
|
||||
errx(1, "%s: no image support by this boot", bootfile);
|
||||
|
||||
imgend = get_uint16(boot + imgstart);
|
||||
imgstart += 2;
|
||||
|
||||
if (imgend < imgstart || imgend >= size_boot)
|
||||
goto badboot;
|
||||
|
||||
/* disklabel exists? */
|
||||
if (get_uint32(boot + labelstart) == MAGIC_DISKLABEL)
|
||||
labelstart = labelend; /* don't destroy disklabel */
|
||||
else
|
||||
labelstart += 2;
|
||||
|
||||
/*
|
||||
* the image fits this boot?
|
||||
*/
|
||||
if (size_img > (imgend - imgstart) + (labelend - labelstart))
|
||||
errx(1, "%s: image doesn't fit (max %d bytes)",
|
||||
imgfile, (imgend - imgstart) + (labelend - labelstart));
|
||||
|
||||
/*
|
||||
* put image into boot
|
||||
*/
|
||||
if (size_img <= (imgend - imgstart)) {
|
||||
memcpy(boot + imgstart, img, size_img);
|
||||
} else {
|
||||
memcpy(boot + imgstart, img, imgend - imgstart);
|
||||
boot[labelstart - 2] = 'i';
|
||||
boot[labelstart - 1] = 'm';
|
||||
memcpy(boot + labelstart, img + (imgend - imgstart),
|
||||
size_img - (imgend - imgstart));
|
||||
}
|
||||
|
||||
/*
|
||||
* write back boot block
|
||||
*/
|
||||
if (write(fd, boot, size_boot) != size_boot)
|
||||
err(1, "%s: write back", bootfile);
|
||||
|
||||
if (close(fd))
|
||||
err(1, "%s: close write", bootfile);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,432 +0,0 @@
|
||||
/* $NetBSD: xpm2bootimg.c,v 1.5 2011/02/21 02:31:58 itohy Exp $ */
|
||||
|
||||
/*
|
||||
* convert XPM format image to boot title format
|
||||
*
|
||||
* written by ITOH Yasufumi, public domain
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int opt_ascii;
|
||||
|
||||
#define IMGWIDTH 56
|
||||
#define IMGHEIGHT 52
|
||||
|
||||
/* if you change this, you must also make changes to the extraction code */
|
||||
#define VALBIT 2
|
||||
#define LENBIT 3
|
||||
#define LENMAX (1<<LENBIT)
|
||||
|
||||
#if VALBIT + LENBIT > 8
|
||||
#error too long encoding --- not portable between architectures in this code
|
||||
#endif
|
||||
|
||||
/* this program may run on cross host, and should be portable */
|
||||
#ifdef __STDC__
|
||||
# define PROTO(x) x
|
||||
#else
|
||||
# define PROTO(x) ()
|
||||
#endif
|
||||
|
||||
static void putbyte PROTO((int c));
|
||||
static void initdot PROTO((void));
|
||||
static void putrun PROTO((int val, int len));
|
||||
static void adddot PROTO((int val));
|
||||
static void flushdot PROTO((void));
|
||||
|
||||
static unsigned rgb16b PROTO((int rgb));
|
||||
static char *destring PROTO((char *str));
|
||||
static char *getline PROTO((void));
|
||||
static void error PROTO((char *msg));
|
||||
int main PROTO((int argc, char *argv[]));
|
||||
|
||||
static int outbuf;
|
||||
static int bufbits;
|
||||
static int curval;
|
||||
static int curlen;
|
||||
|
||||
static int obytes;
|
||||
|
||||
static void
|
||||
putbyte(int c)
|
||||
{
|
||||
static unsigned char wbuf;
|
||||
|
||||
if (c == -1) {
|
||||
if (obytes % 16 && opt_ascii)
|
||||
printf("\n");
|
||||
if (obytes & 1) {
|
||||
if (opt_ascii)
|
||||
printf("\t.byte\t0x%02x\n", wbuf);
|
||||
else
|
||||
putchar(wbuf);
|
||||
}
|
||||
if (opt_ascii)
|
||||
printf("| compressed image %d bytes\n", obytes);
|
||||
return;
|
||||
}
|
||||
if (obytes % 16 == 0 && opt_ascii)
|
||||
printf("\t.word\t");
|
||||
|
||||
obytes++;
|
||||
if (obytes & 1)
|
||||
wbuf = c;
|
||||
else {
|
||||
if (opt_ascii) {
|
||||
if ((obytes >> 1) % 8 != 1)
|
||||
printf(",");
|
||||
printf("0x%04x", (wbuf << 8) | c);
|
||||
} else
|
||||
printf("%c%c", wbuf, c);
|
||||
}
|
||||
|
||||
if (obytes % 16 == 0 && opt_ascii)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
initdot(void)
|
||||
{
|
||||
|
||||
outbuf = bufbits = curval = curlen = obytes = 0;
|
||||
}
|
||||
|
||||
static int put;
|
||||
|
||||
static void
|
||||
putrun(int val, int len)
|
||||
{
|
||||
|
||||
/* fprintf(stderr, "val %d, len %d\n", val, len);*/
|
||||
outbuf <<= VALBIT;
|
||||
outbuf |= val;
|
||||
outbuf <<= LENBIT;
|
||||
outbuf |= len - 1;
|
||||
bufbits += VALBIT + LENBIT;
|
||||
|
||||
if (bufbits >= 8) {
|
||||
putbyte((unsigned char) (outbuf >> (bufbits - 8)));
|
||||
bufbits -= 8;
|
||||
put = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
adddot(int val)
|
||||
{
|
||||
|
||||
if (curval != val) {
|
||||
if (curlen)
|
||||
putrun(curval, curlen);
|
||||
curlen = 0;
|
||||
curval = val;
|
||||
}
|
||||
curlen++;
|
||||
if (curlen == LENMAX) {
|
||||
putrun(val, LENMAX);
|
||||
curlen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
flushdot(void)
|
||||
{
|
||||
|
||||
if (curlen) {
|
||||
putrun(curval, curlen);
|
||||
curlen = 0;
|
||||
}
|
||||
|
||||
if (bufbits) {
|
||||
/* make sure data drain */
|
||||
put = 0;
|
||||
while (put == 0)
|
||||
putrun(curval, LENMAX);
|
||||
}
|
||||
putbyte(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* convert r8g8b8 to g5r5b5i1
|
||||
*/
|
||||
static unsigned
|
||||
rgb16b(int rgb)
|
||||
{
|
||||
unsigned r = rgb >> 16, g = (rgb >> 8) & 0xff, b = rgb & 0xff;
|
||||
unsigned rgb16;
|
||||
|
||||
rgb16 = (g << 8 & 0xf800) | (r << 3 & 0x7c0) | (b >> 2 & 0x3e);
|
||||
|
||||
/*
|
||||
* v v v v v i i i
|
||||
* valid bits used for I bit
|
||||
*/
|
||||
if ((r & 7) + (g & 7) + (b & 7) >= 11)
|
||||
rgb16 |= 1;
|
||||
|
||||
return rgb16;
|
||||
}
|
||||
|
||||
static char *
|
||||
destring(char *str)
|
||||
/* str: must be writable */
|
||||
{
|
||||
size_t len;
|
||||
char *p;
|
||||
|
||||
if (*str != '"' || (len = strlen(str)) < 2)
|
||||
return NULL;
|
||||
p = str + len - 1;
|
||||
if (*p == ',') {
|
||||
if (len < 3)
|
||||
return NULL;
|
||||
p--;
|
||||
}
|
||||
|
||||
if (*p != '"')
|
||||
return NULL;
|
||||
|
||||
*p = '\0';
|
||||
return str + 1;
|
||||
}
|
||||
|
||||
static char *filename;
|
||||
static FILE *infp;
|
||||
static unsigned lineno;
|
||||
|
||||
static char *
|
||||
getline(void)
|
||||
{
|
||||
static char buf[256];
|
||||
char *p;
|
||||
|
||||
if (!fgets(buf, sizeof buf, infp)) {
|
||||
if (ferror(infp)) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
} else
|
||||
return NULL; /* end of input */
|
||||
}
|
||||
lineno++;
|
||||
if (!(p = strchr(buf, '\n'))) {
|
||||
fprintf(stderr, "%s:%d: too long line\n", filename, lineno);
|
||||
exit(1);
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
error(char *msg)
|
||||
{
|
||||
if (!msg)
|
||||
msg = "format error";
|
||||
|
||||
fprintf(stderr, "%s:%d: %s\n", filename, lineno, msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static struct color {
|
||||
int ch;
|
||||
enum col {
|
||||
COL_BLACK, COL_1, COL_2, COL_WHITE
|
||||
} val;
|
||||
} coltbl[32];
|
||||
|
||||
unsigned col1, col2;
|
||||
|
||||
enum col bitmap[IMGHEIGHT][IMGWIDTH];
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *p;
|
||||
unsigned u, colors, xcol, x;
|
||||
char buf[256];
|
||||
int in_oc;
|
||||
char *progname = argv[0];
|
||||
|
||||
/*
|
||||
* parse arg
|
||||
*/
|
||||
if (argc > 1 && !strcmp(argv[1], "-s")) {
|
||||
/*
|
||||
* -s option: output assembler source
|
||||
* (output binary otherwise)
|
||||
*/
|
||||
opt_ascii = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc == 1) {
|
||||
infp = stdin;
|
||||
filename = "stdin";
|
||||
} else if (argc == 2) {
|
||||
if ((infp = fopen(argv[1], "r")) == NULL) {
|
||||
perror(argv[1]);
|
||||
return 1;
|
||||
}
|
||||
filename = argv[1];
|
||||
} else {
|
||||
fprintf(stderr, "usage: %s [file.xpm]\n", progname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* check XPM magic
|
||||
*/
|
||||
if (!(p = getline()))
|
||||
error("short file");
|
||||
|
||||
if (strcmp(p, "/* XPM */"))
|
||||
error((char *) NULL);
|
||||
|
||||
while ((p = getline()) && !(p = destring(p)))
|
||||
;
|
||||
if (!p)
|
||||
error((char *) NULL);
|
||||
|
||||
/*
|
||||
* the first string must be
|
||||
* "56 52 5 1 XPMEXT",
|
||||
*/
|
||||
{
|
||||
unsigned w, h, cpp;
|
||||
|
||||
if (sscanf(p, "%u %u %u %u %s",
|
||||
&w, &h, &colors, &cpp, buf) != 5)
|
||||
error("must be \"56 52 * 1 XPMEXT\"");
|
||||
|
||||
if (w != IMGWIDTH)
|
||||
error("image width must be 56");
|
||||
if (h != IMGHEIGHT)
|
||||
error("image height must be 52");
|
||||
if (cpp != 1)
|
||||
error("chars-per-pixel must be 1");
|
||||
if (strcmp(buf, "XPMEXT"))
|
||||
error("XPMEXT is required");
|
||||
}
|
||||
if (colors > sizeof coltbl / sizeof coltbl[0])
|
||||
error("too many colors");
|
||||
|
||||
/*
|
||||
* read colors
|
||||
* ". c #ffffff",
|
||||
*/
|
||||
xcol = 0;
|
||||
for (u = 0; u < colors; u++) {
|
||||
while ((p = getline()) && !(p = destring(p)))
|
||||
;
|
||||
if (!p)
|
||||
error((char *) NULL);
|
||||
if (sscanf(p, "%c %c %s", buf, buf+1, buf+2) != 3)
|
||||
error((char *) NULL);
|
||||
|
||||
coltbl[u].ch = buf[0];
|
||||
if (buf[2] == '#') {
|
||||
int v;
|
||||
if (sscanf(buf+3, "%x", &v) != 1)
|
||||
error((char *) NULL);
|
||||
if (v == 0)
|
||||
coltbl[u].val = COL_BLACK;
|
||||
else if (v == 0xffffff)
|
||||
coltbl[u].val = COL_WHITE;
|
||||
else if (xcol == 0) {
|
||||
coltbl[u].val = COL_1;
|
||||
col1 = rgb16b(v);
|
||||
xcol++;
|
||||
} else if (xcol == 1) {
|
||||
coltbl[u].val = COL_2;
|
||||
col2 = rgb16b(v);
|
||||
xcol++;
|
||||
} else
|
||||
error("too many colors");
|
||||
} else if (!strcmp(buf+2, "None")) {
|
||||
/*
|
||||
* transparent color is treated as black
|
||||
*/
|
||||
coltbl[u].val = COL_BLACK;
|
||||
} else
|
||||
error("unknown color (symbolic name is not supported)");
|
||||
}
|
||||
|
||||
/*
|
||||
* read bitmaps
|
||||
*/
|
||||
for (u = 0; u < IMGHEIGHT; u++) {
|
||||
|
||||
while ((p = getline()) && !(p = destring(p)))
|
||||
;
|
||||
if (!p)
|
||||
error((char *) NULL);
|
||||
|
||||
if (strlen(p) != IMGWIDTH)
|
||||
error((char *) NULL);
|
||||
|
||||
for (x = 0; x < IMGWIDTH; x++, p++) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < colors; i++)
|
||||
if (coltbl[i].ch == *p)
|
||||
goto found_ch;
|
||||
error("unknown character");
|
||||
|
||||
found_ch:
|
||||
bitmap[u][x] = coltbl[i].val;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* read XPMEXTs and output copyright string
|
||||
*/
|
||||
in_oc = 0;
|
||||
while ((p = getline()) && *p == '\"') {
|
||||
if (!(p = destring(p)))
|
||||
error((char *) NULL);
|
||||
if (!strcmp(p, "XPMEXT copyright"))
|
||||
in_oc = 1;
|
||||
else if (!strncmp(p, "XPMENDEXT", 3))
|
||||
break;
|
||||
else if (!strncmp(p, "XPM", 3))
|
||||
in_oc = 0;
|
||||
else {
|
||||
if (in_oc) {
|
||||
if (opt_ascii)
|
||||
printf("\t.ascii\t\"\\n%s\"\n", p);
|
||||
else
|
||||
printf("\n%s", p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* terminate string */
|
||||
if (opt_ascii)
|
||||
printf("\t.byte\t0\n");
|
||||
else
|
||||
putchar('\0');
|
||||
|
||||
/* output color palette */
|
||||
if (opt_ascii)
|
||||
printf("\t.word\t0x%x,0x%x\n", col1, col2);
|
||||
else
|
||||
printf("%c%c%c%c", col1 >> 8, col1, col2 >> 8, col2);
|
||||
|
||||
/*
|
||||
* scan bitmap and output
|
||||
*/
|
||||
initdot();
|
||||
|
||||
for (u = 0; u < IMGHEIGHT; u++)
|
||||
for (x = 0; x < IMGWIDTH; x++)
|
||||
adddot(bitmap[u][x]);
|
||||
|
||||
flushdot();
|
||||
|
||||
if (opt_ascii)
|
||||
printf("\t.even\n");
|
||||
|
||||
return ferror(stdout);
|
||||
}
|
Loading…
Reference in New Issue
Block a user