summaryrefslogtreecommitdiff
path: root/obsolete/systems/knuth/pxl/chtopx.ch
blob: ca95314ba1783017b5c171ce1e77aa6c6e78d6f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
% Change file for chtopx by Mike Harrison
% History:
% 11/15/83 MH	Initially brought up
% 11/22/83 RKF	Updated to Version 1 of chtopx

@x Only print changes
\pageno=\contentspagenumber \advance\pageno by 1
@y
\pageno=\contentspagenumber \advance\pageno by 1
\let\maybe=\iffalse
@z

@x
@d print(#)==write(error_file,#)
@d print_ln(#)==write_ln(error_file,#)
@y
@d error_file==output	{here, errors go to the standard output}
@d print(#)==write(error_file,#)
@d print_ln(#)==write_ln(error_file,#)
@z

@x
@p program CHtoPX(@!chr_file,@!pxl_file,@!error_file);
@y
@p program CHtoPX(@!chr_file,@!pxl_file,@!output);
@z

@x
var@?@<Global Variables@>@/
@y
var @<Global Variables@>@/
@#
@\@=#include "chext.h"@>@\ {declarations for external C procedures}
@z

@x
@!save_raster_width:integer;    {value read in from |chr_file|}
@y
@!save_raster_width:integer;    {value read in from |chr_file|}
@!new_pointer:integer;		{used to caluculate new pointers}
@!count:integer;
@z

@x
@ Additionally, an error file is provided which contains all error messages
for each character. This file can be specified to be the terminal, in which
case all the error messages will be displayed when the program is run.

@<Glob...@>=
@!error_file:text;
@y
@ In this version, all error messages go to the standard output.  The
definition of |error_file| had to be made earlier because of the
preceding definitions for |print| and |print_ln|.
@z

@x
@<Type...@>=
@!byte=0..255;
@y
@<Type...@>=
@!byte=-128..127;
@z

@x
@!pxl_file:packed file of byte;
@y
@!pxl_file:packed file of byte;
@!pxl_fname,@!chr_fname:packed array [1..40] of char;
@z

@x
@<Open input...@>=
rewrite(pxl_file);@/
reset(chr_file);@/
rewrite(error_file);
@y
@<Open input...@>=
if argc < 3 then begin
    print_ln('Usage: CHtoPX <chr-file> <pxl-file>');
    halt;
end;
argv(1, chr_fname);
reset(chr_file, chr_fname);
argv(2,pxl_fname);
rewrite (pxl_file,pxl_fname);
@z

@x
@p procedure write_pxl(@!oneword:integer);
var k,l,m,n:byte;
begin
k:= oneword div @'100000000;@/
l:=(oneword div @'200000) mod 256;@/
m:=(oneword div 256) mod 256;@/
n:=oneword mod 256;@/
write (pxl_file,k,l,m,n);
end;
@y
@p procedure write_pxl(@!oneword: integer);
var u,v,w,x:byte;
begin
u := getb(oneword,1);@/
v := getb(oneword,2);@/
w := getb(oneword,3);@/
x := getb(oneword,4);@/
write(pxl_file,u,v,w,x);
end;
@z

@x
@p procedure write_half_pxl(oneword:integer);
var m,n:byte;
begin
if oneword < 0 then 
oneword:=(oneword + 65536);
m:=(oneword div 256);@/
n:=(oneword mod 256);@/
write(pxl_file,m,n);
end;
@y
@p procedure write_half_pxl(oneword: integer);
var u,v :byte;
begin
u := getb(oneword,3);@/
v := getb(oneword,4);@/
write(pxl_file,u);@/
write(pxl_file,v);
end;
@z

@x
old_raster_addr:=raster_addr;@/
@y
old_raster_addr:=new_pointer;@/
@z

@x
first_line:=true;@/
@y
first_line:=true;@/
count:=-1;@/
@z

@x
  end;@/
    if raster_found then incr(raster_addr);@/
@y
  end;@/
    incr(count);@/
    if raster_found then incr(raster_addr);@/
@z

@x
until end_of_page or not raster_found;
if not raster_found then skip_to_next_pg;
@y
until end_of_page or not raster_found;
new_pointer := new_pointer + count;@/
if not raster_found then skip_to_next_pg;
@z

@x Boy oh boy is pc literal minded---it rejects null strings in a write!
font_info[chr_index].raster_addr:=old_raster_addr;@/
if not all_match then
begin @/
error ('');   {skip to next line}@/
@y
font_info[chr_index].raster_addr:=old_raster_addr;@/
if not all_match then
begin @/
error (' ');   {skip to next line}@/
@z

@x
check_match(raster_addr,directory_ptr,all_match);
@y
check_match(new_pointer,directory_ptr,all_match);
@z

@x
raster_addr:=1;@/
@y
raster_addr:=1;@/
new_pointer := 1;@/
@z