10 __dpmi_int(0x10, ®s);
12 outportw(0x3c4, 0x0604);
13 outportw(0x3c4, 0x0100);
14 outportb(0x3c2, 0xe7);
15 outportw(0x3c4, 0x0300);
17 outportb(0x3d4, 0x11);
18 outportb(0x3d5, inportb(0x3d5) & 0x7f);
20 outportw(0x3d4, 0x7100);
21 outportw(0x3d4, 0x6301);
22 outportw(0x3d4, 0x6402);
23 outportw(0x3d4, 0x9203);
24 outportw(0x3d4, 0x6604);
25 outportw(0x3d4, 0x8205);
26 outportw(0x3d4, 0x2b06);
27 outportw(0x3d4, 0xb207);
28 outportw(0x3d4, 0x0008);
29 outportw(0x3d4, 0x6109);
30 outportw(0x3d4, 0x1310);
31 outportw(0x3d4, 0xac11);
32 outportw(0x3d4, 0xff12);
33 outportw(0x3d4, 0x3213);
34 outportw(0x3d4, 0x0014);
35 outportw(0x3d4, 0x0715);
36 outportw(0x3d4, 0x1a16);
37 outportw(0x3d4, 0xe317);
39 outportw(0x3d4, 0x3213);
41 ptr1 = (char *) (0xa0000 + __djgpp_conventional_base);
42 outportw(0x3c4, 0x0f02);
43 memset(ptr1, 0, 65535);
51 while ((inportb(0x3da) & 8) == 0);
52 while ((inportb(0x3da) & 8) == 8);
58 void get_block(char page, short x, short y, short width, short height, char *buffer)
61 char *buffer_ptr, *vga_ptr;
63 for (c3 = 0; c3 < 4; c3++) {
64 outportw(0x3ce, (((x + c3) & 3) << 8) + 0x04);
65 for (c1 = 0; (c1 + c3) < width; c1 += 4) {
66 buffer_ptr = &buffer[(c1 + c3) * height];
67 vga_ptr = (char *) (0xa0000 + ((long) page << 15) + (long) y * 100 + ((x + c1 + c3) >> 2) + __djgpp_conventional_base);
68 for (c2 = 0; c2 < height; c2++) {
69 *buffer_ptr = *vga_ptr;
80 void put_block(char page, short x, short y, short width, short height, char *buffer)
83 char *vga_ptr, *buffer_ptr;
85 for (c3 = 0; c3 < 4; c3++) {
86 outportw(0x3c4, ((1 << ((x + c3) & 3)) << 8) + 0x02);
87 for (c1 = 0; (c1 + c3) < width; c1 += 4) {
88 vga_ptr = (char *) (0xa0000 + ((long) page << 15) + (long) y * 100 + ((x + c1 + c3) >> 2) + __djgpp_conventional_base);
89 buffer_ptr = &buffer[(c1 + c3) * height];
90 for (c2 = 0; c2 < height; c2++) {
91 *vga_ptr = *buffer_ptr;
101 void put_text(char page, int x, int y, char *text, char align)
109 if (text == NULL || strlen(text) == 0)
111 if (font_gobs == NULL)
116 while (text[c1] != 0) {
123 if (t1 >= 33 && t1 <= 34)
125 else if (t1 >= 39 && t1 <= 41)
127 else if (t1 >= 44 && t1 <= 59)
129 else if (t1 >= 64 && t1 <= 90)
131 else if (t1 >= 97 && t1 <= 122)
135 else if (t1 == '
\84')
137 else if (t1 == '
\86')
139 else if (t1 == '
\8e')
141 else if (t1 == '
\8f')
143 else if (t1 == '
\94')
145 else if (t1 == '
\99')
149 width += pob_width(image, font_gobs) + 1;
160 cur_x = x - width / 2;
164 while (text[c1] != 0) {
171 if (t1 >= 33 && t1 <= 34)
173 else if (t1 >= 39 && t1 <= 41)
175 else if (t1 >= 44 && t1 <= 59)
177 else if (t1 >= 64 && t1 <= 90)
179 else if (t1 >= 97 && t1 <= 122)
183 else if (t1 == '
\84')
185 else if (t1 == '
\86')
187 else if (t1 == '
\8e')
189 else if (t1 == '
\8f')
191 else if (t1 == '
\94')
193 else if (t1 == '
\99')
197 put_pob(page, cur_x, y, image, font_gobs, 1, mask_pic);
198 cur_x += pob_width(image, font_gobs) + 1;
204 void put_pob(char page, short x, short y, short image, char *pob_data, char mask, char *mask_pic)
208 char *pob_ptr, *vga_ptr, *mask_ptr;
210 long draw_width, draw_height;
213 if (image < 0 || image >= *(short *) (pob_data))
216 pob_offset = *(long *) (pob_data + image * 4 + 2);
218 width = draw_width = *(short *) (pob_data + pob_offset);
219 height = draw_height = *(short *) (pob_data + pob_offset + 2);
220 x -= *(short *) (pob_data + pob_offset + 4);
221 y -= *(short *) (pob_data + pob_offset + 6);
225 if ((x + width) <= 0 || x >= 400)
227 if ((y + height) <= 0 || y >= 256)
234 if ((x + width) > 400)
235 draw_width -= x + width - 400;
237 pob_offset += -y * width;
241 if ((y + height) > 256)
242 draw_height -= y + height - 256;
244 for (c3 = 0; c3 < 4; c3++) {
245 outportw(0x3c4, ((1 << ((x + c3) & 3)) << 8) + 0x02);
246 pob_ptr = &pob_data[pob_offset + c3];
247 vga_ptr = (char *) (0xa0000 + (long) (page << 15) + (long) y * 100L + ((x + c3) >> 2) + __djgpp_conventional_base);
248 mask_ptr = (char *) (mask_pic + (long) y * 400L + x + c3);
249 for (c1 = 0; c1 < draw_height; c1++) {
250 for (c2 = c3; c2 < draw_width; c2 += 4) {
252 if (mask == 0 || (mask == 1 && colour == 0)) {
261 pob_ptr += width - c2 + c3;
262 vga_ptr += (400 - c2 + c3) >> 2;
263 mask_ptr += 400 - c2 + c3;
270 char pob_col(short x1, short y1, short image1, char *pob_data1, short x2, short y2, short image2, char *pob_data2)
273 long pob_offset1, pob_offset2;
274 short width1, width2;
275 short height1, height2;
276 short check_width, check_height;
277 char *pob_ptr1, *pob_ptr2;
279 pob_offset1 = *(long *) (pob_data1 + image1 * 4 + 2);
280 width1 = *(short *) (pob_data1 + pob_offset1);
281 height1 = *(short *) (pob_data1 + pob_offset1 + 2);
282 x1 -= *(short *) (pob_data1 + pob_offset1 + 4);
283 y1 -= *(short *) (pob_data1 + pob_offset1 + 6);
286 pob_offset2 = *(long *) (pob_data2 + image2 * 4 + 2);
287 width2 = *(short *) (pob_data2 + pob_offset2);
288 height2 = *(short *) (pob_data2 + pob_offset2 + 2);
289 x2 -= *(short *) (pob_data2 + pob_offset2 + 4);
290 y2 -= *(short *) (pob_data2 + pob_offset2 + 6);
294 if ((x1 + width1) <= x2)
296 else if ((x1 + width1) <= (x2 + width2)) {
297 pob_offset1 += x2 - x1;
298 check_width = x1 + width1 - x2;
300 pob_offset1 += x2 - x1;
301 check_width = width2;
304 if ((x2 + width2) <= x1)
306 else if ((x2 + width2) <= (x1 + width1)) {
307 pob_offset2 += x1 - x2;
308 check_width = x2 + width2 - x1;
310 pob_offset2 += x1 - x2;
311 check_width = width1;
315 if ((y1 + height1) <= y2)
317 else if ((y1 + height1) <= (y2 + height2)) {
318 pob_offset1 += (y2 - y1) * width1;
319 check_height = y1 + height1 - y2;
321 pob_offset1 += (y2 - y1) * width1;
322 check_height = height2;
325 if ((y2 + height2) <= y1)
327 else if ((y2 + height2) <= (y1 + height1)) {
328 pob_offset2 += (y1 - y2) * width2;
329 check_height = y2 + height2 - y1;
331 pob_offset2 += (y1 - y2) * width2;
332 check_height = height1;
336 pob_ptr1 = (char *) (pob_data1 + pob_offset1);
337 pob_ptr2 = (char *) (pob_data2 + pob_offset2);
338 for (c1 = 0; c1 < check_height; c1++) {
339 for (c2 = 0; c2 < check_width; c2++) {
340 if (*pob_ptr1 != 0 && *pob_ptr2 != 0)
345 pob_ptr1 += width1 - check_width;
346 pob_ptr2 += width2 - check_width;
354 short pob_width(short image, char *pob_data)
356 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2));
360 short pob_height(short image, char *pob_data)
362 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 2);
366 short pob_hs_x(short image, char *pob_data)
368 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 4);
372 short pob_hs_y(short image, char *pob_data)
374 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 6);
378 char read_pcx(FILE * handle, char *buffer, long buf_len, char *pal)
385 fseek(handle, 128, SEEK_CUR);
389 while (ofs1 < buf_len) {
391 if ((a & 0xc0) == 0xc0) {
394 for (c1 = 0; c1 < a; c1++)
401 fseek(handle, 1, SEEK_CUR);
402 for (c1 = 0; c1 < 768; c1++)
403 pal[c1] = fgetc(handle) >> 2;