1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* mt160r.c - program to dump pixel file to Mannesman-Tally 160. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
+ |
#ifdef MSDOS |
12 |
+ |
#include <fcntl.h> |
13 |
+ |
#endif |
14 |
+ |
#include <time.h> |
15 |
|
|
16 |
|
#include "color.h" |
17 |
+ |
#include "resolu.h" |
18 |
|
|
19 |
< |
#define NCOLS 880 /* for wide carriage */ |
19 |
> |
#define NCOLS 880 /* for wide carriage */ |
20 |
|
|
21 |
|
|
22 |
|
main(argc, argv) |
25 |
|
{ |
26 |
|
int i; |
27 |
|
int status = 0; |
28 |
< |
|
28 |
> |
#ifdef MSDOS |
29 |
> |
extern int _fmode; |
30 |
> |
_fmode = O_BINARY; |
31 |
> |
setmode(fileno(stdin), O_BINARY); |
32 |
> |
setmode(fileno(stdout), O_BINARY); |
33 |
> |
#endif |
34 |
|
if (argc < 2) |
35 |
|
status += printp(NULL) == -1; |
36 |
|
else |
47 |
|
int xres, yres; |
48 |
|
COLR scanline[NCOLS]; |
49 |
|
int i; |
50 |
< |
|
50 |
> |
|
51 |
|
if (fname == NULL) { |
52 |
|
input = stdin; |
53 |
|
fname = "<stdin>"; |
61 |
|
return(-1); |
62 |
|
} |
63 |
|
/* get picture dimensions */ |
64 |
< |
if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { |
64 |
> |
if (fgetresolu(&xres, &yres, input) < 0) { |
65 |
|
fprintf(stderr, "%s: bad picture size\n", fname); |
66 |
|
return(-1); |
67 |
|
} |
116 |
|
} |
117 |
|
putchar('\r'); |
118 |
|
putchar('\n'); |
119 |
+ |
fflush(stdout); |
120 |
|
} |
121 |
|
} |
122 |
|
|
127 |
|
{ |
128 |
|
static int cerr[NCOLS]; |
129 |
|
static int err; |
130 |
< |
int b; |
130 |
> |
int b, errp; |
131 |
|
register int isblack; |
132 |
|
|
133 |
|
b = normbright(clr); |
134 |
+ |
errp = err; |
135 |
|
err += b + cerr[x]; |
136 |
|
isblack = err < 128; |
137 |
|
if (!isblack) err -= 256; |
138 |
< |
cerr[x] = err /= 2; |
138 |
> |
err /= 3; |
139 |
> |
cerr[x] = err + errp; |
140 |
|
return(isblack); |
141 |
|
} |