]> 4ch.mooo.com Git - 16.git/blob - 16/dos_gfx.cpp
modified: 16/DOS_GFX.EXE
[16.git] / 16 / dos_gfx.cpp
1 /*\r
2  * LIB.C v1.2a\r
3  *\r
4  * by Robert Schmidt\r
5  * (C)1993 Ztiff Zox Softwear\r
6  *\r
7  * Simple graphics library to accompany the article\r
8  * \r
9  *                                        INTRODUCTION TO MODE X.\r
10  * \r
11  * This library provides the basic functions for initializing and using\r
12  * unchained (planar) 256-color VGA modes.  Currently supported are:\r
13  *\r
14  *        - 320x200\r
15  *        - 320x240\r
16  *\r
17  * Functions are provided for:\r
18  *\r
19  *        - initializing one of the available modes\r
20  *        - setting the start address of the VGA refresh data\r
21  *        - setting active and visible display pages\r
22  *        - writing and reading a single pixel to/from video memory\r
23  *\r
24  * The library is provided as a demonstration only, and is not claimed\r
25  * to be particularly efficient or suited for any purpose.  It has only\r
26  * been tested with Borland C++ 3.1 by the author.  Comments on success\r
27  * or disaster with other compilers are welcome.\r
28  *\r
29  * This file is public domain.  Do with it whatever you'd like, but\r
30  * please don't distribute it without the article.\r
31  *\r
32  * Thanks go out to various helpful netters who spotted the 0xE7 bug\r
33  * in the set320x240x256() function!\r
34  *\r
35  * Modified by sparky4 so it can be compiled in open watcom ^^\r
36  */\r
37 \r
38 \r
39 \r
40 \r
41 /*\r
42  * We 'require' a large data model simply to get rid of explicit 'far'\r
43  * pointers and compiler specific '_fmemset()' functions and the likes.\r
44  */\r
45 #if !defined(__COMPACT__)\r
46 # if !defined(__LARGE__)\r
47 #  if !defined(__HUGE__)\r
48 #   error Large data model required!  Try compiling with 'bcc -ml lib.c'.\r
49 #  endif\r
50 # endif\r
51 #endif\r
52 \r
53 #include <dos.h>\r
54 #include <mem.h>\r
55 #include <conio.h>\r
56 \r
57 //code from old library!\r
58 /*src\lib\*/\r
59 #include "dos_gfx.h"\r
60 #include "lib\x\modex.h"\r
61 \r
62 int old_mode;\r
63 //color \82Ä\82·\82Æ\r
64 int gq = LGQ;\r
65 //\82Ä\82·\82Æ\r
66 int q = 0;\r
67 int bakax = 0, bakay = 0;\r
68 int xx = rand()&0%320, yy = rand()&0%240, sx = 0, sy = 0;\r
69 byte coor;\r
70 \r
71 /*\r
72  * Comment out the following #define if you don't want the testing main()\r
73  * to be included.\r
74  */\r
75 #define TESTING\r
76 \r
77 /*\r
78  * Define the port addresses of some VGA registers.\r
79  */\r
80 #define CRTC_ADDR          0x3d4   /* Base port of the CRT Controller (color) */\r
81 \r
82 #define SEQU_ADDR          0x3c4   /* Base port of the Sequencer */\r
83 #define GRAC_ADDR          0x3ce   /* Base port of the Graphics Controller */\r
84 \r
85 \r
86 /*\r
87  * Make a far pointer to the VGA graphics buffer segment.  Your compiler\r
88  * might not have the MK_FP macro, but you'll figure something out.\r
89  */\r
90 byte *vga = (byte *) MK_FP(0xA000, 0);\r
91 \r
92 //fontAddr = getFont();\r
93 \r
94 /*\r
95  * width and height should specify the mode dimensions.  widthBytes\r
96  * specify the width of a line in addressable bytes.\r
97  */\r
98 unsigned width, height, widthBytes;\r
99 \r
100 /*\r
101  * actStart specifies the start of the page being accessed by\r
102  * drawing operations.  visStart specifies the contents of the Screen\r
103  * Start register, i.e. the start of the visible page.\r
104  */\r
105 unsigned actStart, visStart;\r
106 \r
107 /*\r
108  * set320x200x256_X()\r
109  *        sets mode 13h, then turns it into an unchained (planar), 4-page\r
110  *        320x200x256 mode.\r
111  */\r
112 void set320x200x256_X(void)\r
113                 {\r
114                 union REGS r;\r
115 \r
116                 /* Set VGA BIOS mode 13h: */\r
117                 r.x.ax = 0x0013;\r
118                 int86(0x10, &r, &r);\r
119 \r
120                 /* Turn off the Chain-4 bit (bit 3 at index 4, port 0x3c4): */\r
121                 outpw(SEQU_ADDR, 0x0604);\r
122 \r
123                 /* Turn off word mode, by setting the Mode Control register\r
124                 of the CRT Controller (index 0x17, port 0x3d4): */\r
125                 outpw(CRTC_ADDR, 0xE317);\r
126 \r
127                 /* Turn off doubleword mode, by setting the Underline Location\r
128                    register (index 0x14, port 0x3d4): */\r
129                 outpw(CRTC_ADDR, 0x0014);\r
130 \r
131                 /* Clear entire video memory, by selecting all four planes, then\r
132                    writing 0 to entire segment. */\r
133                 outpw(SEQU_ADDR, 0x0F02);\r
134                 memset(vga+1, 0, 0xffff); /* stupid size_t exactly 1 too small */\r
135                 vga[0] = 0;\r
136 \r
137                 /* Update the global variables to reflect dimensions of this\r
138                    mode.  This is needed by most future drawing operations. */\r
139                 width              = 320;\r
140                 height  = 200;\r
141 \r
142                 /* Each byte addresses four pixels, so the width of a scan line\r
143                    in *bytes* is one fourth of the number of pixels on a line. */\r
144                 widthBytes = width / 4;\r
145 \r
146                 /* By default we want screen refreshing and drawing operations\r
147                    to be based at offset 0 in the video segment. */\r
148                 actStart = visStart = 0;\r
149                 }\r
150 \r
151 /*\r
152  * setActiveStart() tells our graphics operations which address in video\r
153  * memory should be considered the top left corner.\r
154  */\r
155 void setActiveStart(unsigned offset)\r
156                 {\r
157                 actStart = offset;\r
158                 }\r
159 \r
160 /*\r
161  * setVisibleStart() tells the VGA from which byte to fetch the first\r
162  * pixel when starting refresh at the top of the screen.  This version\r
163  * won't look very well in time critical situations (games for\r
164  * instance) as the register outputs are not synchronized with the\r
165  * screen refresh.  This refresh might start when the high byte is\r
166  * set, but before the low byte is set, which produces a bad flicker.\r
167  */\r
168 void setVisibleStart(unsigned offset)\r
169                 {\r
170                 visStart = offset;\r
171                 outpw(CRTC_ADDR, 0x0C);          /* set high byte */\r
172                 outpw(CRTC_ADDR+1, visStart >> 8);\r
173                 outpw(CRTC_ADDR, 0x0D);          /* set low byte */\r
174                 outpw(CRTC_ADDR+1, visStart & 0xff);\r
175                 }\r
176 \r
177 /*\r
178  * setXXXPage() sets the specified page by multiplying the page number\r
179  * with the size of one page at the current resolution, then handing the\r
180  * resulting offset value over to the corresponding setXXXStart()\r
181  * function.  The first page is number 0.\r
182  */\r
183 void setActivePage(int page)\r
184                 {\r
185                 setActiveStart(page * widthBytes * height);\r
186                 }\r
187 \r
188 void setVisiblePage(int page)\r
189                 {\r
190                 setVisibleStart(page * widthBytes * height);\r
191                 }\r
192 \r
193 void putPixel_X(int x, int y, byte color)\r
194                 {\r
195                 /* Each address accesses four neighboring pixels, so set\r
196                    Write Plane Enable according to which pixel we want\r
197                    to modify.  The plane is determined by the two least\r
198                    significant bits of the x-coordinate: */\r
199                 outp(0x3c4, 0x02);\r
200                 outp(0x3c5, 0x01 << (x & 3));\r
201 \r
202                 /* The offset of the pixel into the video segment is\r
203                    offset = (width * y + x) / 4, and write the given\r
204                    color to the plane we selected above.  Heed the active\r
205                    page start selection. */\r
206                 vga[(unsigned)(widthBytes * y) + (x / 4) + actStart] = color;\r
207 \r
208                 }\r
209 \r
210 byte getPixel_X(int x, int y)\r
211                 {\r
212                 /* Select the plane from which we must read the pixel color: */\r
213                 outpw(GRAC_ADDR, 0x04);\r
214                 outpw(GRAC_ADDR+1, x & 3);\r
215 \r
216                 return vga[(unsigned)(widthBytes * y) + (x / 4) + actStart];\r
217 \r
218                 }\r
219 \r
220 void set320x240x256_X(void)\r
221                 {\r
222                 /* Set the unchained version of mode 13h: */\r
223                 set320x200x256_X();\r
224 \r
225                 /* Modify the vertical sync polarity bits in the Misc. Output\r
226                    Register to achieve square aspect ratio: */\r
227                 outp(0x3C2, 0xE3);\r
228 \r
229                 /* Modify the vertical timing registers to reflect the increased\r
230                    vertical resolution, and to center the image as good as\r
231                    possible: */\r
232                 outpw(0x3D4, 0x2C11);              /* turn off write protect */\r
233                 outpw(0x3D4, 0x0D06);              /* vertical total */\r
234                 outpw(0x3D4, 0x3E07);              /* overflow register */\r
235                 outpw(0x3D4, 0xEA10);              /* vertical retrace start */\r
236                 outpw(0x3D4, 0xAC11);              /* vertical retrace end AND wr.prot */\r
237                 outpw(0x3D4, 0xDF12);              /* vertical display enable end */\r
238                 outpw(0x3D4, 0xE715);              /* start vertical blanking */\r
239                 outpw(0x3D4, 0x0616);              /* end vertical blanking */\r
240 \r
241                 /* Update mode info, so future operations are aware of the\r
242                    resolution */\r
243                 height = 240;\r
244 \r
245                 }\r
246 \r
247 \r
248 /*-----------XXXX-------------*/\r
249 /*tile*/\r
250 void putColorBox_X(int x, int y, int w, int h, byte color) {\r
251         outp(0x3c4, 0x02);\r
252 \r
253         int curx, cury;\r
254         unsigned drawptr;\r
255         for (curx=x; curx<(x+w); curx++) {\r
256                 outp(0x3c5, 0x01 << (curx & 3));\r
257                 drawptr = (unsigned)(widthBytes * y) + (curx / 4) + actStart;\r
258                 for (cury=0; cury<h; cury++) {\r
259                         vga[drawptr] = color;\r
260                         drawptr += widthBytes;\r
261                 }\r
262         }\r
263 }\r
264 \r
265 void vScroll(int rows)\r
266 {\r
267         // Scrolling = current start + (rows * bytes in a row)\r
268         setVisibleStart(visStart + (rows * width));\r
269 }\r
270 \r
271 /*OFFSET = 0\r
272 WHILE NOT FINISHED DO\r
273   OFFSET = OFFSET + 80\r
274   IF OFFSET >= (200 * 80) THEN OFFSET = 0\r
275   DRAW TO ROW 200\r
276   SET VGA OFFSET = OFFSET\r
277   DRAW TO ROW -1 (was row 0 before scroll)\r
278 END WHILE*//*\r
279 void scrolly(){\r
280         int OFFSET = 0\r
281         WHILE NOT FINISHED DO\r
282                 OFFSET = OFFSET + 80\r
283                 IF OFFSET >= (240 * 80) THEN OFFSET = 0\r
284                 RAW TO ROW 240\r
285                 SET VGA OFFSET = OFFSET\r
286                 DRAW TO ROW -1 (was row 0 before scroll)\r
287         }\r
288 }\r
289 */\r
290 //---------------------------------------------------\r
291 //\r
292 // Use the bios to get the address of the 8x8 font\r
293 //\r
294 // You need a font if you are going to draw text.\r
295 //\r
296 \r
297 int far *\r
298 getFont()\r
299 {\r
300         union REGPACK rg;\r
301         int seg;\r
302         int off;\r
303         memset(&rg, 0, sizeof(rg));\r
304 \r
305         rg.w.ax = 0x1130;\r
306         rg.h.bh = 0x03;\r
307         intr(0x10, &rg);\r
308         seg = rg.w.es;\r
309         off = rg.w.bp;\r
310         \r
311 \r
312         return (int far *)MK_FP(seg, off);\r
313 }\r
314 \r
315 void drawChar(int x, int y, int color, byte c)\r
316 {\r
317                 int i, j;\r
318                 int mask;\r
319                 int far *font = getFont() + (c * 8);\r
320 \r
321                 for (i = 0; i < 8; i++)\r
322                 {\r
323                                 mask = *font;\r
324                                 for (j = 0; j < 8; j++)\r
325                                 {\r
326                                                 if (mask & 0x80)\r
327                                                 {\r
328                                                                 //pixel(x + j, y + i, color);\r
329                                                                 putPixel_X(x + j, y + i, color);\r
330                                                 }\r
331                                                 mask <<= 1;\r
332                                 }\r
333                                 font++;\r
334                 }\r
335 }\r
336 \r
337 void drawText(int x, int y, int color, byte string)\r
338 {\r
339                 while (string)\r
340                 {\r
341                                 drawChar(x, y, color, string);\r
342                                 x += 8;\r
343                                 string++;\r
344                 }\r
345 }\r
346 \r
347 /////////////////////////////////////////////////////////////////////////////\r
348 //                                                                         //\r
349 // setvideo() - This function Manages the video modes                                     //\r
350 //                                                                         //\r
351 /////////////////////////////////////////////////////////////////////////////\r
352 void setvideo(/*byte mode, */int vq){\r
353                 union REGS in, out;\r
354 \r
355                 if(!vq){ // deinit the video\r
356                                 // change to the video mode we were in before we switched to mode 13h\r
357                                 in.h.ah = 0x00;\r
358                                 in.h.al = old_mode;\r
359                                 int86(0x10, &in, &out);\r
360 \r
361                 }else if(vq == 1){ // init the video\r
362                                 // get old video mode\r
363                                 in.h.ah = 0xf;\r
364                                 int86(0x10, &in, &out);\r
365                                 old_mode = out.h.al;\r
366 \r
367                                 // enter mode\r
368                                 set320x240x256_X();\r
369                 }\r
370 }\r
371 \r
372 /////////////////////////////////////////////////////////////////////////////\r
373 //                                                                                                                                               //\r
374 // cls() - This clears the screen to the specified color, on the VGA or on //\r
375 //               the Virtual screen.                                                                                     //\r
376 //                                                                                                                                               //\r
377 /////////////////////////////////////////////////////////////////////////////\r
378 void cls(byte color, byte *Where){\r
379                 _fmemset(Where, color, width*(height*17));\r
380 }\r
381 \r
382 //color \82Ä\82·\82Æ\r
383 int colortest(){\r
384                 if(gq < NUM_COLORS){\r
385                                 cls(gq, vga);\r
386                                 gq++;\r
387                 }else gq = 0;\r
388                 return gq;\r
389 }\r
390 \r
391 //color \82Ä\82·\82Æ\r
392 int colorz(){\r
393                 if(gq < HGQ){\r
394 //----            cls(gq, vaddr);\r
395                                 cls(gq, vga);\r
396                                 gq++;\r
397                 }else gq = LGQ;\r
398                 return gq;\r
399 }\r
400 \r
401 //slow spectrum down\r
402 void ssd(int svq){\r
403                 if(sy < height+1){\r
404                                 if(sx < width+1){\r
405                                                 //plotpixel(xx, yy, coor, vga);\r
406                                                 //ppf(sx, sy, coor, vga);\r
407                                                 putPixel_X(sx, sy, coor);\r
408                                                 //printf("%d %d %d %d\n", sx, sy, svq, coor);\r
409                                                 sx++;\r
410                                 }else sx = 0;\r
411                                 if(sx == width){\r
412                                                 sy++;\r
413                                                 if(svq == 7) coor++;\r
414                                                 if(sy == height && svq == 8) coor = rand()%NUM_COLORS;\r
415                                 }\r
416                 }else sy = 0;\r
417 }\r
418 \r
419 /*-----------ding-------------*/\r
420 int ding(int q){\r
421 \r
422         if(yy<height){\r
423                 setActivePage(0);\r
424                 setVisiblePage(0);\r
425         }else if((height)<yy<(height*2)){\r
426                 setActivePage(1);\r
427                 setVisiblePage(1);\r
428         }else if((height*2)<yy<(height*3)){\r
429                 setActivePage(2);\r
430                 setVisiblePage(2);\r
431         }\r
432                 int d3y;\r
433 \r
434 //++++  if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;\r
435                 if((q == 2\r
436                 ||q==4\r
437                 ||q==16\r
438                 ) && gq == BONK-1){\r
439                                                 if(coor < HGQ && coor < LGQ) coor = LGQ;\r
440                                                 if(coor < HGQ){\r
441                                                                 coor++;\r
442                                 }else{ coor = LGQ;\r
443                                                 bakax = rand()%3; bakay = rand()%3;\r
444                                 }\r
445                 }\r
446 \r
447                 if(q == 8){ colorz(); return gq; }else\r
448                 if(q == 10){ ssd(q); /*printf("%d\n", coor);*/ }else\r
449                 if(q == 5){ colortest(); return gq; }else\r
450                 if(q == 11){ colorz(); delay(100); return gq; }\r
451                 if(q == 6){\r
452                                 coor = rand()%NUM_COLORS;\r
453 //----            cls(coor, vaddr);\r
454                                 cls(coor, vga);\r
455                                 //updatevbuff();\r
456                 }\r
457 \r
458                 if(q == 7 || q== 9){\r
459                                 if(gq < HGQ){\r
460                                                 if(q == 7) ssd(q);\r
461                                                 if(q == 9){ ssd(q); coor++; }\r
462                                                 gq++;\r
463                                 }else gq = LGQ;\r
464                 }\r
465                 if((q<5 && gq<BONK) || (q==16 && gq<BONK)){ // the number variable make the colors more noticable\r
466                                 if(q==1){\r
467                                                 if(xx==width){bakax=0;}\r
468                                                 if(xx==0){bakax=1;}\r
469                                                 if(yy==height){bakay=0;}\r
470                                                 if(yy==0){bakay=1;}\r
471                                 }else if(q==3){\r
472                                                 if(xx!=width||yy!=height){\r
473                                                                 if(xx==0){bakax=1;bakay=-1;d3y=1;}\r
474                                                                 if(yy==0){bakax=1;bakay=0;d3y=1;}\r
475                                                                 if(xx==width){bakax=-1;bakay=-1;d3y=1;}\r
476                                                                 if(yy==height){bakax=1;bakay=0;d3y=1;}\r
477                                                 }else if(xx==width&&yy==height) xx=yy=0;\r
478                                 }\r
479                                 if(q==3){\r
480                                                 if(d3y){\r
481                                                                 if(bakay<0){\r
482                                                                                 yy--;\r
483                                                                                 d3y--;\r
484                                                                 }else\r
485                                                                 if(bakay>0){\r
486                                                                                 yy++;\r
487                                                                                 d3y--;\r
488                                                                 }\r
489                                                 }\r
490                                                 if(bakax<0){\r
491                                                                 xx--;\r
492                                                 }else\r
493                                                 if(bakax>0){\r
494                                                                 xx++;\r
495                                                 }\r
496                                 }else{\r
497                                                 if(q==16)\r
498                                                 {\r
499                                                                 if(!bakax){\r
500                                                                                 xx--;//=TILEWH;\r
501                                                                 }else if(bakax>0){\r
502                                                                                 xx++;//=TILEWH;\r
503                                                                 }\r
504                                                                 if(!bakay){\r
505                                                                                 yy--;//=TILEWH;\r
506                                                                 }else if(bakay>0){\r
507                                                                                 yy++;//=TILEWH;\r
508                                                                 }\r
509                                                 }else{\r
510                                                                 if(!bakax){\r
511                                                                                 xx-=TILEWH;\r
512                                                                 }else if(bakax>1){\r
513                                                                                 xx+=TILEWH;\r
514                                                                 }\r
515                                                                 if(!bakay){\r
516                                                                                 yy-=TILEWH;\r
517                                                                 }else if(bakay>1){\r
518                                                                                 yy+=TILEWH;\r
519                                                                 }\r
520                                                 }\r
521                                 }\r
522                                 // fixer\r
523 //                              if(q!=16){\r
524 //if(q!=16)\r
525                                                 if(xx<0) xx=width;\r
526                                                 if(yy<0) yy=(height*3);\r
527                                                 if(xx>width) xx=0;\r
528                                                 if(yy>(height*3)) yy=0;\r
529 //                              }\r
530 \r
531 //interesting effects\r
532                                 if(q==16)\r
533                                 {\r
534                                 int tx=0,ty=0;\r
535                                 tx+=xx+16;\r
536                                 ty+=yy+16;\r
537                                 putPixel_X(tx, ty, coor);\r
538                                 //drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor);\r
539                                 //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH);\r
540 \r
541                                 // plot the pixel\r
542 //----            ppf(xx, yy, coor, vga);\r
543                                 }else if(xx>=0 && xx<width && yy>=0 && yy<height){\r
544                                         putColorBox_X(xx, yy, TILEWH, TILEWH, coor);\r
545 //++++0000                                      putPixel_X(xx, yy, coor);\r
546                                 } \r
547 \r
548 //----            if(q==2) ppf(rand()%, rand()%height, 0, vga);\r
549                                 if(q==2) putColorBox_X(rand()%width, rand()%(height*3), TILEWH, TILEWH, 0);\r
550                                 if(q==16) putPixel_X(rand()%width, rand()%(height*3), 0);\r
551                                 if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; }\r
552                                 gq++;\r
553 //if(xx<0||xx>320||yy<0||yy>240)\r
554 //        printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy));\r
555 //        printf("%d\n", getPixel_X(xx,yy));\r
556 //0000\r
557 //        drawText(0, 0, 15, getPixel_X(xx,yy));\r
558                 }else gq = LGQ;\r
559                 return gq;\r
560 }\r
561 \r
562 \r
563 /*\r
564  * The library testing routines follows below.\r
565  */\r
566 \r
567 \r
568 #ifdef TESTING\r
569 \r
570 #include <stdio.h>\r
571 #include <conio.h>\r
572 \r
573 void doTest(void)\r
574                 {\r
575                 int p, x, y, pages;\r
576 \r
577                 /* This is the way to calculate the number of pages available. */\r
578                 pages = 65536L/(widthBytes*height); // apparently this takes the A000 address\r
579 \r
580                 printf("%d\n", pages);\r
581 \r
582                 for (p = 0; p <= pages; ++p)\r
583                                 {\r
584                                 setActivePage(p);\r
585 \r
586                                 /* On each page draw a single colored border, and dump the palette\r
587                                    onto a small square about the middle of the page. */\r
588 \r
589                                    //{\r
590                                                 for (x = 0; x <= width; ++x)\r
591                                                                 {\r
592                                                                 putPixel_X(x, 0, p+1);\r
593                                                                 if(p!=pages) putPixel_X(x, height-1, p+1);\r
594                                                                                 else putPixel_X(x, 99-1, p+1);\r
595                                                                 }\r
596 \r
597                                                 for (y = 0; y <= height; ++y)\r
598                                                                 {\r
599                                                                 putPixel_X(0, y, p+1);\r
600                                                                 if(p!=pages) putPixel_X(width-1, y, p+1);\r
601                                                                                 else putPixel_X(width-1, y, p+1);\r
602                                                                 }\r
603 \r
604                                                 for (x = 0; x < 16; ++x)\r
605                                                                 for (y = 0; y < 16; ++y)\r
606                                                                                 putPixel_X(x+(p+2)*16, y+(p+2)*16, x + y*16);\r
607                                                 //}\r
608 \r
609 //                              drawText(0, 0, 15, p);\r
610 \r
611                                 }\r
612 \r
613                 /* Each pages will now contain a different image.  Let the user cycle\r
614                    through all the pages by pressing a key. */\r
615                 for (p = 0; p <= pages; ++p)\r
616                                 {\r
617                                 setVisiblePage(p);\r
618                                 //drawText(0, 240, 15, "bakapi");\r
619                                 getch();\r
620                                 }\r
621 \r
622                 }\r
623 \r
624 /*\r
625  * Library test (program) entry point.\r
626  */\r
627 \r
628 int main(void)\r
629                 {\r
630                 int key,d;\r
631                 // main variables\r
632                 d=1; // switch variable\r
633                 key=4; // default screensaver number\r
634 //        puts("First, have a look at the 320x200 mode.  I will draw some rubbish");\r
635 //        puts("on all of the four pages, then let you cycle through them by");\r
636 //        puts("hitting a key on each page.");\r
637 //        puts("Press a key when ready...");\r
638 //        getch();\r
639 \r
640 //        doTest();\r
641 \r
642 //        puts("Then, check out Mode X, 320x240 with 3 (and a half) pages.");\r
643 //        puts("Press a key when ready...");\r
644 //        getch();\r
645 \r
646 //++++0000\r
647                 setvideo(1);\r
648 //mxInit();\r
649 // screen savers\r
650 \r
651 /*while(d!=0){ // on!\r
652                                 if(!kbhit()){ // conditions of screen saver\r
653                                                 ding(key);\r
654                                 }else{\r
655                                                 setvideo(0);\r
656                                                 // user imput switch\r
657                                                 printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 5 to quit.\n", getch());  // prompt the user\r
658                                                 scanf("%d", &key);\r
659                                                 //if(key==3){xx=yy=0;} // crazy screen saver wwww\r
660                                                 if(key==5) d=0;\r
661                                                 setvideo(1);\r
662                                 }\r
663                 }*/ // else off\r
664                 while(!kbhit()){ // conditions of screen saver\r
665                         ding(4);\r
666                 }\r
667                 //end of screen savers\r
668                 doTest();\r
669 \r
670                 while(!kbhit()){ // conditions of screen saver\r
671                         vScroll(-1);\r
672                 }\r
673 //++++0000\r
674                 setvideo(0);\r
675 //mxTerm();\r
676 //mxGetVersion();\r
677                 puts("Where to next?  It's your move! wwww");\r
678                 printf("bakapi ver. 1.04.09.02\nis made by sparky4\81i\81\86\83Ö\81\85\81j feel free to use it ^^\nLicence: GPL v2\n");\r
679                 return 0;\r
680                 }\r
681 \r
682 #endif\r