annotate 3rdparty/utils/viewgif/gifwin.c @ 3226:9749d0dfc4a2

Changed a puls PC to rts to save cycles
author David Ladd <drencor-xeen@users.sourceforge.net>
date Sat, 20 Jan 2018 19:32:22 -0600
parents aaae5eac20e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1188
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
1 /*
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
2 * gifwin.c - window functions for ViewGIF 2.0
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
3 * by Vaughn Cato
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
4 */
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
5
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
6 #include "viewgif.h"
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
7
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
8 char *mapgpb();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
9 extern int errno;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
10
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
11 checksig()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
12 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
13 char buf[6];
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
14
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
15 fread(buf, sizeof(*buf), 6, infile);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
16 if (strncmp(buf, "GIF", 3) != 0)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
17 fatal("file is not a GIF file");
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
18 if (strncmp(&buf[3], "87a", 3) != 0)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
19 fatal("Unknown GIF version number");
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
20 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
21
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
22 perror(str)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
23 char *str;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
24 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
25 fprintf(stderr, "%s: error\n", str);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
26 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
27
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
28 error(str, errnum)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
29 char *str;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
30 int errnum;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
31 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
32 fprintf(stderr, "viewgif: %s\n", str);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
33 exit(errnum);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
34 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
35
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
36 sleep(ticks)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
37 int ticks;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
38 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
39 #asm
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
40 ldx 4,s
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
41 os9 F$Sleep
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
42 #endasm
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
43 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
44
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
45 static char *ustext[] = {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
46 "OS9 ViewGIF 2.0 by Vaughn Cato\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
47 "usage: viewgif <filename> [-<option> ...]\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
48 " displays a gif picture\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
49 "\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
50 " options:\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
51 " -d[[=]dfactor] Set dithering factor, default is 0\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
52 " -a Align to pixels\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
53 " -u[=]<filename> Create/use a color usage file\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
54 " -m[=]<magfact> Set magnification factor (1-64)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
55 " -x[=]<start x> Set start x (0-64)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
56 " -y[=]<start y> Set start y (0-64)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
57 " -v[[=]<filename>] Generate vef format picture\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
58 " -g grey scale picture (average color brite)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
59 " -g2 grey scale picture (max color brite)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
60 " -g3 grey scale picture (NTSC color brite)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
61 " -r Use random generator instead of table\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
62 " -s Silent. No info printed\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
63 " -i Extended information\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
64 " -n No display\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
65 " -p[[=]seconds] Pause time (default 0)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
66 " -c Use current screen\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
67 " -f Disable flicker\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
68 " -b[=]<britefact> Set brightness (1-16)\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
69 " -z Zap unused global color map entries\n",
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
70 NULL
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
71 };
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
72
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
73 usage()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
74 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
75 register char **uscan;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
76
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
77 for (uscan = ustext; *uscan != NULL; uscan++)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
78 fputs(*uscan, stderr);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
79 exit(1);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
80 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
81
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
82 initwin(firstscreen, oldpath)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
83 bool firstscreen;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
84 int oldpath;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
85 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
86 register bool newwin;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
87
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
88 newwin = (oldpath == -1);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
89
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
90 if (newwin) {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
91 if (!newscrn && firstscreen) {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
92 /* just use stdout */
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
93 actwin = oldpath = 1;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
94 dwend();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
95 } else if ((actwin = oldpath = open("/w", 3)) == -1)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
96 exit(errno);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
97 } else {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
98 actwin = oldpath;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
99 dwend();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
100 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
101
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
102 dwset(gmode ? 7 : 8, 0, 0, gmode ? 80 : 40, 24, 0, 0, 0);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
103 curoff();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
104 select();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
105 flushwin();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
106
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
107 if (newwin && firstscreen) {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
108 groupnum = getpid();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
109 bufnum = 1;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
110 getblk(groupnum, bufnum, 0, 0, 640, 1);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
111 flushwin();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
112 if ((gpbufptr = mapgpb(actwin, groupnum, bufnum, 1)) == NULL)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
113 exit(errno);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
114 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
115
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
116 return actwin;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
117 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
118
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
119 dwset(sty, cpx, cpy, szx, szy, prn1, prn2, prn3)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
120 int sty, cpx, cpy, szx, szy, prn1, prn2, prn3;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
121 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
122 static char outstr[] = {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
123 0x1b, 0x20, 0, 0, 0, 0, 0, 0, 0, 0
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
124 };
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
125 int size;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
126
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
127 outstr[2] = sty;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
128 outstr[3] = cpx;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
129 outstr[4] = cpy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
130 outstr[5] = szx;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
131 outstr[6] = szy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
132 if (sty > 0 && sty <= 8) {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
133 outstr[7] = prn1;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
134 outstr[8] = prn2;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
135 outstr[9] = prn3;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
136 size = sizeof(outstr);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
137 } else
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
138 size = sizeof(outstr) - 3;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
139 writemem(outstr, size);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
140 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
141
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
142 dwend()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
143 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
144 static char outstr[] = {0x1b, 0x24};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
145
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
146 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
147 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
148
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
149 select()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
150 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
151 static char outstr[] = {0x1b, 0x21};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
152
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
153 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
154 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
155
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
156 bell()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
157 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
158 char c = 7;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
159 writemem(&c, 1);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
160 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
161
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
162 palette(prn, ctn)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
163 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
164 static char outstr[] = {0x1b, 0x31, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
165
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
166 outstr[2] = prn;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
167 outstr[3] = ctn;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
168 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
169 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
170
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
171 point(x, y)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
172 int x, y;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
173 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
174 static char outstr[] = {0x1b, 0x42, 0, 0, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
175
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
176 *(int *) &outstr[2] = x;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
177 *(int *) &outstr[4] = y;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
178 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
179 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
180
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
181 lineto(x, y)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
182 int x, y;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
183 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
184 static char outstr[] = {0x1b, 0x46, 0, 0, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
185
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
186 *(int *) &outstr[2] = x;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
187 *(int *) &outstr[4] = y;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
188 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
189 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
190
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
191 fcolor(c)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
192 int c;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
193 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
194 static char outstr[] = {0x1b, 0x32, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
195
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
196 outstr[2] = c;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
197 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
198 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
199
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
200 border(c)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
201 int c;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
202 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
203 static char outstr[] = {0x1b, 0x34, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
204
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
205 outstr[2] = c;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
206 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
207 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
208
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
209 SetDPtr(x, y)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
210 int x, y;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
211 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
212 static char outstr[] = {0x1b, 0x40, 0, 0, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
213
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
214 *(int *) &outstr[2] = x;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
215 *(int *) &outstr[4] = y;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
216 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
217 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
218
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
219 curoff()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
220 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
221 static char outstr[] = {0x05, 0x20};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
222
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
223 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
224 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
225
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
226 getblk(grp, bfn, cpx, cpy, szx, szy)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
227 int grp, bfn, cpx, cpy, szx, szy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
228 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
229 static char outstr[] = {0x1b, 0x2c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
230
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
231 outstr[2] = grp;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
232 outstr[3] = bfn;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
233 *(int *) (&outstr[4]) = cpx;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
234 *(int *) (&outstr[6]) = cpy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
235 *(int *) (&outstr[8]) = szx;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
236 *(int *) (&outstr[10]) = szy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
237 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
238 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
239
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
240 putblk(grp, bfn, cpx, cpy)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
241 int grp, bfn, cpx, cpy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
242 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
243 static char outstr[] = {0x1b, 0x2d, 0, 0, 0, 0, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
244
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
245 outstr[2] = grp;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
246 outstr[3] = bfn;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
247 *(int *) (&outstr[4]) = cpx;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
248 *(int *) (&outstr[6]) = cpy;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
249 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
250 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
251
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
252 killbuf(grp, bfn)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
253 int grp, bfn;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
254 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
255 static char outstr[] = {0x1b, 0x2a, 0, 0};
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
256
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
257 outstr[2] = grp;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
258 outstr[3] = bfn;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
259 writemem(outstr, sizeof(outstr));
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
260 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
261
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
262 char *
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
263 mapgpb(path, grp, bfn, action)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
264 int path, grp, bfn, action;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
265 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
266 #asm
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
267 lda 7,s group
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
268 ldb 9,s buffer
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
269 tfr d,x ->X
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
270 lda 5,s path
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
271 ldb #$SS.MpGPB setstat code
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
272 pshs y
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
273 ldy 10+2,s action (1 => map, 0 => unmap)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
274 os9 I$SetStt
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
275 puls y
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
276 bcc _mapgpb1
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
277 clra error--
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
278 std errno,y save error code,
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
279 ldx #0 return NULL pointer
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
280 _mapgpb1: tfr x,d move pointer into position for return
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
281 #endasm
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
282 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
283
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
284 static char outbuf[256];
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
285 static DIRECT char *outptr = outbuf;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
286 static DIRECT int bufleft = sizeof(outbuf);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
287
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
288 writemem(str, size)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
289 register char *str;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
290 register int size;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
291 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
292 while (size > bufleft) {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
293 size -= bufleft;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
294 while (--bufleft >= 0)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
295 *outptr++ = *str++;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
296 flushwin();
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
297 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
298 bufleft -= size;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
299 while (--size >= 0)
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
300 *outptr++ = *str++;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
301 }
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
302
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
303 flushwin()
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
304 {
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
305 write(actwin, outbuf, outptr - outbuf);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
306 outptr = outbuf;
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
307 bufleft = sizeof(outbuf);
aaae5eac20e1 Provded by James Jones
boisy
parents:
diff changeset
308 }