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);
48 void wait_vrt(int mix)
51 while ((inportb(0x3da) & 8) == 0)
53 while ((inportb(0x3da) & 8) == 8)
56 while ((inportb(0x3da) & 8) == 0);
57 while ((inportb(0x3da) & 8) == 8);
61 void clear_page(int page, int color)
63 outportw(0x3c4, 0x0f02);
64 memset((char *) (0xa0000 - __djgpp_base_address), 0, 32768);
67 void clear_lines(int page, int y, int count, int color)
71 outportw(0x3c4, 0x0f02);
72 for (i=0; i<count; i++)
74 memset((char *) (0xa0000 + (i+y) * 100 + __djgpp_conventional_base), 0, 100);
77 int get_pixel(int page, int x, int y)
79 outportw(0x3ce, (((x) & 3) << 8) + 0x04);
80 //outportw(0x3c4, ((1 << ((x) & 3)) << 8) + 0x02);
81 return *(char *) (0xa0000 + (y * 100 + (x >> 2)) + ((long) page << 15) - __djgpp_base_address);
84 void set_pixel(int page, int x, int y, int color)
86 //outportw(0x3ce, (((x) & 3) << 8) + 0x04);
87 outportw(0x3c4, ((1 << ((x) & 3)) << 8) + 0x02);
88 *(char *) (0xa0000 + (y * 100 + (x >> 2)) + ((long) page << 15) - __djgpp_base_address) = color;
91 void flippage(int page)
93 outportw(0x3d4, (page << 23) + 0x0d);
94 outportw(0x3d4, ((page << 15) & 0xff00) + 0x0c);
98 void get_block(char page, short x, short y, short width, short height, char *buffer)
101 char *buffer_ptr, *vga_ptr;
103 for (c3 = 0; c3 < 4; c3++) {
104 outportw(0x3ce, (((x + c3) & 3) << 8) + 0x04);
105 for (c1 = 0; (c1 + c3) < width; c1 += 4) {
106 buffer_ptr = &buffer[(c1 + c3) * height];
107 vga_ptr = (char *) (0xa0000 + ((long) page << 15) + (long) y * 100 + ((x + c1 + c3) >> 2) + __djgpp_conventional_base);
108 for (c2 = 0; c2 < height; c2++) {
109 *buffer_ptr = *vga_ptr;
120 void put_block(char page, short x, short y, short width, short height, char *buffer)
123 char *vga_ptr, *buffer_ptr;
125 for (c3 = 0; c3 < 4; c3++) {
126 outportw(0x3c4, ((1 << ((x + c3) & 3)) << 8) + 0x02);
127 for (c1 = 0; (c1 + c3) < width; c1 += 4) {
128 vga_ptr = (char *) (0xa0000 + ((long) page << 15) + (long) y * 100 + ((x + c1 + c3) >> 2) + __djgpp_conventional_base);
129 buffer_ptr = &buffer[(c1 + c3) * height];
130 for (c2 = 0; c2 < height; c2++) {
131 *vga_ptr = *buffer_ptr;
141 void put_text(char page, int x, int y, char *text, char align)
149 if (text == NULL || strlen(text) == 0)
151 if (font_gobs == NULL)
156 while (text[c1] != 0) {
163 if (t1 >= 33 && t1 <= 34)
165 else if (t1 >= 39 && t1 <= 41)
167 else if (t1 >= 44 && t1 <= 59)
169 else if (t1 >= 64 && t1 <= 90)
171 else if (t1 >= 97 && t1 <= 122)
189 width += pob_width(image, font_gobs) + 1;
200 cur_x = x - width / 2;
204 while (text[c1] != 0) {
211 if (t1 >= 33 && t1 <= 34)
213 else if (t1 >= 39 && t1 <= 41)
215 else if (t1 >= 44 && t1 <= 59)
217 else if (t1 >= 64 && t1 <= 90)
219 else if (t1 >= 97 && t1 <= 122)
237 put_pob(page, cur_x, y, image, font_gobs, 1, mask_pic);
238 cur_x += pob_width(image, font_gobs) + 1;
244 void put_pob(char page, short x, short y, short image, char *pob_data, char mask, char *mask_pic)
248 char *pob_ptr, *vga_ptr, *mask_ptr;
250 long draw_width, draw_height;
253 if (image < 0 || image >= *(short *) (pob_data))
256 pob_offset = *(long *) (pob_data + image * 4 + 2);
258 width = draw_width = *(short *) (pob_data + pob_offset);
259 height = draw_height = *(short *) (pob_data + pob_offset + 2);
260 x -= *(short *) (pob_data + pob_offset + 4);
261 y -= *(short *) (pob_data + pob_offset + 6);
265 if ((x + width) <= 0 || x >= 400)
267 if ((y + height) <= 0 || y >= 256)
274 if ((x + width) > 400)
275 draw_width -= x + width - 400;
277 pob_offset += -y * width;
281 if ((y + height) > 256)
282 draw_height -= y + height - 256;
284 for (c3 = 0; c3 < 4; c3++) {
285 outportw(0x3c4, ((1 << ((x + c3) & 3)) << 8) + 0x02);
286 pob_ptr = &pob_data[pob_offset + c3];
287 vga_ptr = (char *) (0xa0000 + (long) (page << 15) + (long) y * 100L + ((x + c3) >> 2) + __djgpp_conventional_base);
288 mask_ptr = (char *) (mask_pic + (long) y * 400L + x + c3);
289 for (c1 = 0; c1 < draw_height; c1++) {
290 for (c2 = c3; c2 < draw_width; c2 += 4) {
292 if (mask == 0 || (mask == 1 && colour == 0)) {
301 pob_ptr += width - c2 + c3;
302 vga_ptr += (400 - c2 + c3) >> 2;
303 mask_ptr += 400 - c2 + c3;
310 char pob_col(short x1, short y1, short image1, char *pob_data1, short x2, short y2, short image2, char *pob_data2)
313 long pob_offset1, pob_offset2;
314 short width1, width2;
315 short height1, height2;
316 short check_width, check_height;
317 char *pob_ptr1, *pob_ptr2;
319 pob_offset1 = *(long *) (pob_data1 + image1 * 4 + 2);
320 width1 = *(short *) (pob_data1 + pob_offset1);
321 height1 = *(short *) (pob_data1 + pob_offset1 + 2);
322 x1 -= *(short *) (pob_data1 + pob_offset1 + 4);
323 y1 -= *(short *) (pob_data1 + pob_offset1 + 6);
326 pob_offset2 = *(long *) (pob_data2 + image2 * 4 + 2);
327 width2 = *(short *) (pob_data2 + pob_offset2);
328 height2 = *(short *) (pob_data2 + pob_offset2 + 2);
329 x2 -= *(short *) (pob_data2 + pob_offset2 + 4);
330 y2 -= *(short *) (pob_data2 + pob_offset2 + 6);
334 if ((x1 + width1) <= x2)
336 else if ((x1 + width1) <= (x2 + width2)) {
337 pob_offset1 += x2 - x1;
338 check_width = x1 + width1 - x2;
340 pob_offset1 += x2 - x1;
341 check_width = width2;
344 if ((x2 + width2) <= x1)
346 else if ((x2 + width2) <= (x1 + width1)) {
347 pob_offset2 += x1 - x2;
348 check_width = x2 + width2 - x1;
350 pob_offset2 += x1 - x2;
351 check_width = width1;
355 if ((y1 + height1) <= y2)
357 else if ((y1 + height1) <= (y2 + height2)) {
358 pob_offset1 += (y2 - y1) * width1;
359 check_height = y1 + height1 - y2;
361 pob_offset1 += (y2 - y1) * width1;
362 check_height = height2;
365 if ((y2 + height2) <= y1)
367 else if ((y2 + height2) <= (y1 + height1)) {
368 pob_offset2 += (y1 - y2) * width2;
369 check_height = y2 + height2 - y1;
371 pob_offset2 += (y1 - y2) * width2;
372 check_height = height1;
376 pob_ptr1 = (char *) (pob_data1 + pob_offset1);
377 pob_ptr2 = (char *) (pob_data2 + pob_offset2);
378 for (c1 = 0; c1 < check_height; c1++) {
379 for (c2 = 0; c2 < check_width; c2++) {
380 if (*pob_ptr1 != 0 && *pob_ptr2 != 0)
385 pob_ptr1 += width1 - check_width;
386 pob_ptr2 += width2 - check_width;
394 short pob_width(short image, char *pob_data)
396 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2));
400 short pob_height(short image, char *pob_data)
402 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 2);
406 short pob_hs_x(short image, char *pob_data)
408 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 4);
412 short pob_hs_y(short image, char *pob_data)
414 return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 6);
418 char read_pcx(FILE * handle, char *buffer, long buf_len, char *pal)
425 fseek(handle, 128, SEEK_CUR);
429 while (ofs1 < buf_len) {
431 if ((a & 0xc0) == 0xc0) {
434 for (c1 = 0; c1 < a; c1++)
441 fseek(handle, 1, SEEK_CUR);
442 for (c1 = 0; c1 < 768; c1++)
443 pal[c1] = fgetc(handle) >> 2;