4 void open_screen(void) {
9 __dpmi_int(0x10, ®s);
11 outportw(0x3c4, 0x0604);
12 outportw(0x3c4, 0x0100);
13 outportb(0x3c2, 0xe7);
14 outportw(0x3c4, 0x0300);
16 outportb(0x3d4, 0x11);
17 outportb(0x3d5, inportb(0x3d5) & 0x7f);
19 outportw(0x3d4, 0x7100);
20 outportw(0x3d4, 0x6301);
21 outportw(0x3d4, 0x6402);
22 outportw(0x3d4, 0x9203);
23 outportw(0x3d4, 0x6604);
24 outportw(0x3d4, 0x8205);
25 outportw(0x3d4, 0x2b06);
26 outportw(0x3d4, 0xb207);
27 outportw(0x3d4, 0x0008);
28 outportw(0x3d4, 0x6109);
29 outportw(0x3d4, 0x1310);
30 outportw(0x3d4, 0xac11);
31 outportw(0x3d4, 0xff12);
32 outportw(0x3d4, 0x3213);
33 outportw(0x3d4, 0x0014);
34 outportw(0x3d4, 0x0715);
35 outportw(0x3d4, 0x1a16);
36 outportw(0x3d4, 0xe317);
38 outportw(0x3d4, 0x3213);
40 ptr1 = (char *)(0xa0000 + __djgpp_conventional_base);
41 outportw(0x3c4, 0x0f02);
42 memset(ptr1, 0, 65535);
49 while( (inportb(0x3da) & 8) == 0);
50 while( (inportb(0x3da) & 8) == 8);
55 /*void get_block(char page, short x, short y, short width, short height, char *buffer) {
57 char *buffer_ptr, *vga_ptr;
59 for (c3 = 0; c3 < 4; c3++) {
60 outportw(0x3ce, ( ( (x + c3) & 3) << 8) + 0x04);
61 for (c1 = 0; (c1 + c3) < width; c1 += 4) {
62 buffer_ptr = &buffer[(c1 + c3) * height];
63 vga_ptr = (char *)(0xa0000 + ( (long)page << 15) + (long)y * 100 + ( (x + c1 + c3) >> 2) + __djgpp_conventional_base);
64 for (c2 = 0; c2 < height; c2++) {
65 *buffer_ptr = *vga_ptr;
75 /*void put_block(char page, short x, short y, short width, short height, char *buffer) {
77 char *vga_ptr, *buffer_ptr;
79 for (c3 = 0; c3 < 4; c3++) {
80 outportw(0x3c4, ( (1 << ( (x + c3) & 3) ) << 8) + 0x02);
81 for (c1 = 0; (c1 + c3) < width; c1 += 4) {
82 vga_ptr = (char *)(0xa0000 + ( (long)page << 15) + (long)y * 100 + ( (x + c1 + c3) >> 2) + __djgpp_conventional_base);
83 buffer_ptr = &buffer[(c1 + c3) * height];
84 for (c2 = 0; c2 < height; c2++) {
85 *vga_ptr = *buffer_ptr;
95 void put_text(char page, int x, int y, char *text, char align) {
102 if (text == NULL || strlen(text) == 0)
104 if (font_gobs == NULL)
109 while (text[c1] != 0) {
116 if (t1 >= 33 && t1 <= 34)
118 else if (t1 >= 39 && t1 <= 41)
120 else if (t1 >= 44 && t1 <= 59)
122 else if (t1 >= 64 && t1 <= 90)
124 else if (t1 >= 97 && t1 <= 122)
128 else if (t1 == '
\84')
130 else if (t1 == '
\86')
132 else if (t1 == '
\8e')
134 else if (t1 == '
\8f')
136 else if (t1 == '
\94')
138 else if (t1 == '
\99')
142 width += pob_width(image, font_gobs) + 1;
153 cur_x = x - width / 2;
157 while (text[c1] != 0) {
164 if (t1 >= 33 && t1 <= 34)
166 else if (t1 >= 39 && t1 <= 41)
168 else if (t1 >= 44 && t1 <= 59)
170 else if (t1 >= 64 && t1 <= 90)
172 else if (t1 >= 97 && t1 <= 122)
176 else if (t1 == '
\84')
178 else if (t1 == '
\86')
180 else if (t1 == '
\8e')
182 else if (t1 == '
\8f')
184 else if (t1 == '
\94')
186 else if (t1 == '
\99')
190 put_pob(page, cur_x, y, image, font_gobs, 1, mask_pic);
191 cur_x += pob_width(image, font_gobs) + 1;
197 void put_pob(char page, short x, short y, short image, char *pob_data, char mask, char *mask_pic) {
200 char *pob_ptr, *vga_ptr, *mask_ptr;
202 long draw_width, draw_height;
205 if (image < 0 || image >= *(short *)(pob_data) )
208 pob_offset = *(long *)(pob_data + image * 4 + 2);
210 width = draw_width = *(short *)(pob_data + pob_offset);
211 height = draw_height = *(short *)(pob_data + pob_offset + 2);
212 x -= *(short *)(pob_data + pob_offset + 4);
213 y -= *(short *)(pob_data + pob_offset + 6);
217 if ( (x + width) <= 0 || x >= 400)
219 if ( (y + height) <= 0 || y >= 256)
226 if ( (x + width) > 400)
227 draw_width -= x + width - 400;
229 pob_offset += -y * width;
233 if ( (y + height) > 256)
234 draw_height -= y + height - 256;
236 for (c3 = 0; c3 < 4; c3++) {
237 outportw(0x3c4, ( (1 << ( (x + c3) & 3) ) << 8) + 0x02);
238 pob_ptr = &pob_data[pob_offset + c3];
239 vga_ptr = (char *)(0xa0000 + (long)(page << 15) + (long)y * 100L + ( (x + c3) >> 2) + __djgpp_conventional_base);
240 mask_ptr = (char *)(mask_pic + (long)y * 400L + x + c3);
241 for (c1 = 0; c1 < draw_height; c1++) {
242 for (c2 = c3; c2 < draw_width; c2 += 4) {
244 if (mask == 0 || (mask == 1 && colour == 0) ) {
253 pob_ptr += width - c2 + c3;
254 vga_ptr += (400 - c2 + c3) >> 2;
255 mask_ptr += 400 - c2 + c3;
262 char pob_col(short x1, short y1, short image1, char *pob_data1, short x2, short y2, short image2, char *pob_data2) {
264 long pob_offset1, pob_offset2;
265 short width1, width2;
266 short height1, height2;
267 short check_width, check_height;
268 char *pob_ptr1, *pob_ptr2;
270 pob_offset1 = *(long *)(pob_data1 + image1 * 4 + 2);
271 width1 = *(short *)(pob_data1 + pob_offset1);
272 height1 = *(short *)(pob_data1 + pob_offset1 + 2);
273 x1 -= *(short *)(pob_data1 + pob_offset1 + 4);
274 y1 -= *(short *)(pob_data1 + pob_offset1 + 6);
277 pob_offset2 = *(long *)(pob_data2 + image2 * 4 + 2);
278 width2 = *(short *)(pob_data2 + pob_offset2);
279 height2 = *(short *)(pob_data2 + pob_offset2 + 2);
280 x2 -= *(short *)(pob_data2 + pob_offset2 + 4);
281 y2 -= *(short *)(pob_data2 + pob_offset2 + 6);
285 if ( (x1 + width1) <= x2)
287 else if ( (x1 + width1) <= (x2 + width2) ) {
288 pob_offset1 += x2 - x1;
289 check_width = x1 + width1 - x2;
292 pob_offset1 += x2 - x1;
293 check_width = width2;
297 if ( (x2 + width2) <= x1)
299 else if ( (x2 + width2) <= (x1 + width1) ) {
300 pob_offset2 += x1 - x2;
301 check_width = x2 + width2 - x1;
304 pob_offset2 += x1 - x2;
305 check_width = width1;
309 if ( (y1 + height1) <= y2)
311 else if ( (y1 + height1) <= (y2 + height2) ) {
312 pob_offset1 += (y2 - y1) * width1;
313 check_height = y1 + height1 - y2;
316 pob_offset1 += (y2 - y1) * width1;
317 check_height = height2;
321 if ( (y2 + height2) <= y1)
323 else if ( (y2 + height2) <= (y1 + height1) ) {
324 pob_offset2 += (y1 - y2) * width2;
325 check_height = y2 + height2 - y1;
328 pob_offset2 += (y1 - y2) * width2;
329 check_height = height1;
333 pob_ptr1 = (char *)(pob_data1 + pob_offset1);
334 pob_ptr2 = (char *)(pob_data2 + pob_offset2);
335 for (c1 = 0; c1 < check_height; c1++) {
336 for (c2 = 0; c2 < check_width; c2++) {
337 if (*pob_ptr1 != 0 && *pob_ptr2 != 0)
342 pob_ptr1 += width1 - check_width;
343 pob_ptr2 += width2 - check_width;
351 short pob_width(short image, char *pob_data) {
352 return *(short *)(pob_data + *(long *)(pob_data + image * 4 + 2) );
356 short pob_height(short image, char *pob_data) {
357 return *(short *)(pob_data + *(long *)(pob_data + image * 4 + 2) + 2);
361 short pob_hs_x(short image, char *pob_data) {
362 return *(short *)(pob_data + *(long *)(pob_data + image * 4 + 2) + 4);
366 short pob_hs_y(short image, char *pob_data) {
367 return *(short *)(pob_data + *(long *)(pob_data + image * 4 + 2) + 6);
371 char read_pcx(FILE *handle, char *buffer, long buf_len, char *pal) {
377 fseek(handle, 128, SEEK_CUR);
381 while (ofs1 < buf_len) {
383 if ( (a & 0xc0) == 0xc0) {
386 for (c1 = 0; c1 < a; c1++)
394 fseek(handle, 1, SEEK_CUR);
395 for (c1 = 0; c1 < 768; c1++)
396 pal[c1] = fgetc(handle) >> 2;