home *** CD-ROM | disk | FTP | other *** search
/ Mega A/V / mega_av.zip / mega_av / DEMOS / FRACT386.ZIP / FRACT386.C next >
Text File  |  1988-11-06  |  21KB  |  513 lines

  1. /*
  2.     FRACT386 - 386-specific Mandelbrot/Julia Fractal Generator
  3.     C-code        Version 3.0        By Bert Tyler
  4. */
  5.  
  6. struct videoinfo {        /* All we need to know about a Video Adapter */
  7.     char    name[40];    /* Adapter name (IBM EGA, etc)        */
  8.     int    videomodeax;    /* begin with INT 10H, AX=(this)    */
  9.     int    videomodebx;    /*        ...and BX=(this)    */
  10.     int    videomodecx;    /*        ...and CX=(this)    */
  11.     int    videomodedx;    /*        ...and DX=(this)    */
  12.     int    dotmode;    /* video access method used by asm code    */
  13.                 /*    1 == BIOS 10H, AH=12,13 (SLOW)    */
  14.                 /*    2 == access like EGA/VGA    */
  15.                 /*    3 == access like MCGA        */
  16.     int    xdots;        /* number of dots across the screen    */
  17.     int    ydots;        /* number of dots down the screen    */
  18.     int    colors;        /* number of colors available        */
  19.     char    comment[40];    /* Comments (UNTESTED, etc)        */
  20.     };
  21.  
  22. struct videoinfo videomode[] = {
  23. /*
  24.     Feel free to add your favorite video adapter to the following table.
  25.     Just remember that only the first 50 entries get displayed and
  26.     assigned Function keys.
  27.  
  28. --Adapter/Mode------|---INT 10H---|Dot-|-Resolution-|------Comments-----------
  29. -----Name-----------|-AX--BX-CX-DX|Mode|X-|-Y-|Color|-------------------------
  30. */
  31. "IBM Low-Rez EGA",   0x0d, 0, 0, 0, 2, 320, 200, 16, "Quick, but chunky",
  32. "IBM 16-Color EGA",  0x10, 0, 0, 0, 2, 640, 350, 16, "Slower, but lots nicer",
  33. "IBM 256-Color MCGA",0x13, 0, 0, 0, 3, 320, 200,256, "Quick, LOTS of colors",
  34. "IBM 16-Color VGA",  0x12, 0, 0, 0, 2, 640, 480, 16, "Nice, high resolution",
  35. "IBM 4-Color CGA",   0x05, 0, 0, 0, 1, 320, 200,  4, "(Ugh, Yuck, Bleah)",
  36. "IBM Hi-Rez B&W CGA",0x06, 0, 0, 0, 1, 640, 200,  2, "(Hi-Rez Ugh, Yuck)",
  37. "IBM B&W EGA",       0x0f, 0, 0, 0, 2, 640, 350,  2, "(Monochrome EGA)",
  38. "IBM B&W VGA",       0x11, 0, 0, 0, 2, 640, 480,  2, "(Monochrome VGA)",
  39. "IBM Med-Rez EGA",   0x0e, 0, 0, 0, 2, 640, 200, 16, "(Silly, but there!)",
  40. "ATI EGA Wonder",    0x51, 0, 0, 0, 1, 640, 480, 16, "UNTESTED: may not work",
  41. "ATI EGA Wonder",    0x52, 0, 0, 0, 1, 800, 560, 16, "UNTESTED: may not work",
  42. "Everex EVGA",       0x70, 2, 0, 0, 2, 800, 600, 16, "UNTESTED: may not work",
  43. "Everex EVGA",       0x70,19, 0, 0, 1, 512, 480,256, "UNTESTED: may not work",
  44. "Everex EVGA",       0x70,21, 0, 0, 1, 640, 350,256, "UNTESTED: may not work",
  45. "Paradise VGA",      0x5e, 0, 0, 0, 1, 640, 400,256, "UNTESTED: may not work",
  46. "Paradise VGA",      0x5f, 0, 0, 0, 1, 640, 480,256, "UNTESTED: may not work",
  47. "Paradise VGA",      0x58, 0, 0, 0, 2, 800, 600, 16, "Tested OK by Chris Green",
  48. "Paradise EGA-480",  0x50, 0, 0, 0, 1, 640, 480, 16, "UNTESTED: may not work",
  49. "VEGA VGA",          0x2d, 0, 0, 0, 1, 640, 350,256, "UNTESTED: may not work",
  50. "VEGA VGA",          0x5e, 0, 0, 0, 1, 640, 400,256, "UNTESTED: may not work",
  51. "VEGA VGA",          0x2e, 0, 0, 0, 1, 640, 480,256, "UNTESTED: may not work",
  52. "VEGA VGA",          0x27, 0, 0, 0, 1, 720, 512, 16, "UNTESTED: may not work",
  53. "VEGA VGA",          0x2f, 0, 0, 0, 1, 720, 512,256, "UNTESTED: may not work",
  54. "VEGA VGA",          0x29, 0, 0, 0, 1, 800, 600, 16, "UNTESTED: may not work",
  55. "VEGA VGA",          0x30, 0, 0, 0, 1, 800, 600,256, "UNTESTED: may not work",
  56. "VEGA VGA",          0x36, 0, 0, 0, 1, 960, 720, 16, "UNTESTED: may not work",
  57. "VEGA VGA",          0x37, 0, 0, 0, 1,1024, 768, 16, "UNTESTED: may not work",
  58. "Video-7 Vram VGA", 0x6f05,0x60,0,0,1, 752, 410, 16, "UNTESTED: may not work",
  59. "Video-7 Vram VGA", 0x6f05,0x61,0,0,1, 720, 540, 16, "UNTESTED: may not work",
  60. "Video-7 Vram VGA", 0x6f05,0x62,0,0,1, 800, 600, 16, "UNTESTED: may not work",
  61. "Video-7 Vram VGA", 0x6f05,0x63,0,0,1,1024, 768,  2, "UNTESTED: may not work",
  62. "Video-7 Vram VGA", 0x6f05,0x64,0,0,1,1024, 768,  4, "UNTESTED: may not work",
  63. "Video-7 Vram VGA", 0x6f05,0x65,0,0,1,1024, 768, 16, "UNTESTED: may not work",
  64. "Video-7 Vram VGA", 0x6f05,0x66,0,0,1, 640, 400,256, "UNTESTED: may not work",
  65. "Video-7 Vram VGA", 0x6f05,0x67,0,0,1, 640, 480,256, "UNTESTED: may not work",
  66. "Video-7 Vram VGA", 0x6f05,0x68,0,0,1, 720, 540,256, "UNTESTED: may not work",
  67. "Video-7 Vram VGA", 0x6f05,0x69,0,0,1, 800, 600,256, "UNTESTED: may not work",
  68. "AT&T 6300",         0x41, 0, 0, 0, 1, 640, 200, 16, "UNTESTED: may not work",
  69. "AT&T 6300",         0x48, 0, 0, 0, 1, 640, 400,  2, "UNTESTED: may not work",
  70. "AT&T 6300",         0x42, 0, 0, 0, 1, 640, 400, 16, "UNTESTED: may not work",
  71. "END",                  3, 0, 0, 0, 0,   0,   0,  0, "Marks END of the List"
  72.     };
  73.  
  74. int    maxvideomode;        /* size of the above list */
  75. int    adapter;        /* Video Adapter chosen from above list    */
  76.  
  77. char *fkeys[] = {        /* Function Key names for display table */
  78.     "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
  79.     "SF1","SF2","SF3","SF4","SF5","SF6","SF7","SF8","SF9","SF10",
  80.     "CF1","CF2","CF3","CF4","CF5","CF6","CF7","CF8","CF9","CF10",
  81.     "AF1","AF2","AF3","AF4","AF5","AF6","AF7","AF8","AF9","AF10",
  82.     "Alt-1","Alt-2","Alt-3","Alt-4","Alt-5",
  83.     "Alt-6","Alt-7","Alt-8","Alt-9","Alt-0",
  84.     "END"};
  85. char *accessmethod[] = {" ","B"," "," "}; /* BIOS access indicator */
  86.  
  87. #define    FUDGEFACTOR    29        /* fudge all values up by 2**this */
  88. #define MAXHISTORY    100        /* save this many historical rcds */
  89.  
  90. long    history[MAXHISTORY][6];    /* for historical (HOME Key) purposes */
  91.  
  92. /*
  93.    the following variables are out here only so
  94.    that the assembler routine can get at them easily
  95. */
  96.     int    dotmode;            /* video access method      */
  97.                         /* 1 == use the BIOS (ugh)  */
  98.                         /* 2 == access like EGA/VGA */
  99.                         /* 3 == access like MCGA    */
  100.     int    xdots, ydots;            /* # of dots on the screen  */
  101.     int    colors;                /* maximum colors available */
  102.     int    maxit;                /* try this many iterations */
  103.     int    ixmin, ixmax, iymin, iymax;    /* corners of the zoom box  */
  104.  
  105.     int    julia;                /* if == 0, use Mandelbrot  */
  106.     long    creal, cimag;            /* real, imag'ry parts of C */
  107.     long    lx0[2048], ly0[2048];        /* x, y grid (2K x 2K max)  */
  108.  
  109. main(argc,argv)
  110. int argc;
  111. char *argv[];
  112. {
  113.     long    jxmin, jxmax, jymin, jymax;    /* "Julia mode" entry point */
  114.     long    xmin, xmax, ymin, ymax;        /* screen corner values */
  115.     long    delx, dely;            /* screen pixel increments */
  116.     long    fudge;                /* 2**fudgefactor    */
  117.     double    atof(),xxmin,xxmax,yymin,yymax;    /* (printf) screen corners */
  118.     double    ccreal, ccimag;            /* Julia Set Constant */
  119.     int    xstep, ystep;            /* zoom-box increment values */
  120.     int    axmode, bxmode, cxmode, dxmode;    /* video mode (BIOS ##) */
  121.     int    historyptr;            /* pointer into history tbl */
  122.     int    zoomoff;            /* = 0 when zoom is disabled */
  123.     int    kbdchar;            /* keyboard key-hit value */
  124.     int    more, kbdmore;            /* continuation variables */
  125.     int    i,j;                /* temporary loop counters */
  126.  
  127. if ((i=abs(cputype())) != 386) {        /* oops. not a 386 */
  128.     printf("\n\n\007");
  129.     printf(" I'm sorry.   This program requires an 80386-based PC, and my\n");
  130.     printf(" poking around has determined that this is more like an 80%d.", i);
  131.     printf("\n\n");
  132.     exit(1);
  133.     }
  134.  
  135. for (maxvideomode = 0;                /* get size of adapter list */
  136.     strcmp(videomode[maxvideomode].name,"END") != 0
  137.         && maxvideomode < 50;    /* that's all the Fn keys we got! */
  138.     maxvideomode++);
  139.  
  140. maxit = 150;                    /* max iterations */
  141.  
  142. fudge = 1; fudge = fudge << FUDGEFACTOR;    /* fudged value for printfs */
  143.  
  144. restart:                /* insert key re-starts here */
  145.  
  146. julia = 0;                    /* use the Mandelbrot set */
  147. creal = 0; cimag = 0;                /* dummy C-values         */
  148.                         /* grid for full Mandel set */
  149. xmax =  4; xmax = xmax << (FUDGEFACTOR-2);    /* xmax == 1.0        */
  150. xmin = -8; xmin = xmin << (FUDGEFACTOR-2);    /* xmin == -2.0        */
  151. ymax =  6; ymax = ymax << (FUDGEFACTOR-2);    /* ymax == 1.5        */
  152. ymin = -6; ymin = ymin << (FUDGEFACTOR-2);    /* ymin == -1.5        */
  153.  
  154. if (argc == 3 || argc == 7) {            /* Julia Set Override */
  155.     julia = 1;
  156.     ccreal = atof(argv[1]);
  157.     ccimag = atof(argv[2]);
  158.     if (ccreal < -1.99 || ccreal > 1.99) ccreal = .0001;
  159.     if (ccimag < -1.99 || ccimag > 1.99) ccimag = .0001;
  160.     ccreal = ccreal * fudge; creal = ccreal;
  161.     ccimag = ccimag * fudge; cimag = ccimag;
  162.     jxmin = xmin;  jxmax = xmax;  jymin = ymin;  jymax = ymax;
  163.     xmax =  7; xmax = xmax << (FUDGEFACTOR-2);    /* xmax =  1.75 */
  164.     xmin = -7; xmin = xmin << (FUDGEFACTOR-2);    /* xmin = -1.75 */
  165.     ymax =  7; ymax = ymax << (FUDGEFACTOR-2);    /* ymax =  1.75 */
  166.     ymin = -7; ymin = ymin << (FUDGEFACTOR-2);    /* ymin = -1.75 */
  167.     }
  168.  
  169. if (argc == 5 || argc == 7) {            /* starting grid override */
  170.     xxmin = atof(argv[argc-4]);
  171.     xxmax = atof(argv[argc-3]);
  172.     yymin = atof(argv[argc-2]);
  173.     yymax = atof(argv[argc-1]);
  174.     /* keep it reasonable, guys  -- max-min MUST be < 4 */
  175.     if (xxmin < -2.0  || xxmin > 1.99) xxmin = -2.0;
  176.     if (xxmax < -2.0  || xxmax > 1.99) xxmax =  1.99;
  177.     if (yymin < -1.99 || yymin > 1.99) yymin = -1.99;
  178.     if (yymax < -1.99 || yymax > 1.99) yymax =  1.99;
  179.     xxmin = xxmin * fudge; xmin = xxmin;
  180.     xxmax = xxmax * fudge; xmax = xxmax + 100;
  181.     yymin = yymin * fudge; ymin = yymin - 100;
  182.     yymax = yymax * fudge; ymax = yymax;
  183.     }
  184.  
  185. setvideomode(3,0,0,0);            /* switch to text mode */
  186.  
  187. printf("\n\n\n");
  188. printf("FRACT386                      Version 3.0                by Bert Tyler\n");
  189. printf("\n");
  190. printf("The useful keys you can hit while this program is running are:\n");
  191. printf("\n");
  192. printf("  PageUp            Shrink the Zoom Box (Zoom in)  \n");
  193. printf("  PageDown          Expand the Zoom Box (Zoom out) \n");
  194. printf("  Cursor Keys       Move the Zoom Box Left, Right, Up, or Down (Panning)\n");
  195. printf("  Ctrl-Cursor-Keys  Pan as above, but quickly (may require an Enhanced KBD)\n");
  196. printf("  End or Enter      Redraw (full screen) the area inside the Zoom Box \n");
  197. printf("  F1,F2,F3,F4...    Select a new Video Mode and THEN Redraw\n");
  198. printf("                    (See Instructions Below for a complete Video Mode list)\n");
  199. printf("  Home              Redraw Previous screen (you can 'back out' recursively)\n");
  200. printf("  Tab               Display the Screen or Zoom-Box X and Y Coordinates\n");
  201. printf("  Spacebar          Mandelbrot/Julia Set toggle (read the README file first)\n");
  202. printf("  Insert            Restart the program (at this screen)\n");
  203. printf("  Delete or Esc     Stop the program and return to MSDOS\n");
  204. printf("\n");
  205. printf("Hitting any key while the program is drawing will stop the drawing immediately\n");
  206. printf("to perform the function.   This means you can begin Zooming and Panning (or\n");
  207. printf("anything else) as soon as you see something interesting.  If you haven't yet\n");
  208. printf("hit a key when the screen is finished, the program will beep and wait for you.\n");
  209. printf("\n");
  210. printf("Please Select your Video Mode by hitting a Function Key (F1, F2, F3, F4,...) \n");
  211. printf("    (Or hit the <ENTER> key to see a complete list of supported Video modes) \n");
  212. printf("The program will begin with the full Mandelbrot Set as a starting point. ");
  213.  
  214. j = maxvideomode;                /* init for video modes scan */
  215. for (;;) {                    /* wait for valid Fn Key */
  216.     kbdchar = getakey();
  217.     if (kbdchar >= 1059 && kbdchar < 1069    /* F1 - F10 */
  218.      && kbdchar < 1059 + maxvideomode) {
  219.         adapter = kbdchar - 1059;    /* use this adapter initially */
  220.         break;
  221.         }
  222.     if (kbdchar >= 1084 && kbdchar < 1114    /* SF1 - AF10 */
  223.      && kbdchar < 1074 + maxvideomode) {
  224.         adapter = kbdchar - 1074;    /* use this adapter initially */
  225.         break;
  226.         }
  227.     if (kbdchar >= 1120 && kbdchar < 1130    /* Alt-1 thru Alt-0 */
  228.      && kbdchar < 1080 + maxvideomode) {
  229.         adapter = kbdchar - 1080;    /* use this adapter initially */
  230.         break;
  231.         }
  232.     if (kbdchar == 1082) goto restart;    /* restart pgm on Insert Key */
  233.     if (kbdchar == 1000) exit(0);        /* Control-C */
  234.     if (kbdchar == 27) exit(0);        /* exit to DOS on Escape Key */
  235.     if (kbdchar == 1083) exit(0);        /* exit to DOS on Delete Key */
  236.     if (kbdchar == 13) {            /* <ENTER> key: display adapter list */
  237.         j += 14;            /* display next page */
  238.         if (j >= maxvideomode) j = 0;    /* (or 1st page)     */
  239.         printf("\n\n\nThe current list of supported Video Adapters and Modes includes:\n\n");
  240.         printf("      %-20s   Resolution Colors   %-30s\n\n",
  241.             "Video Adapter & Mode", "     Comments");
  242.         for (i = j; i < maxvideomode && i < j + 14; i++) {
  243.             printf("%-5s %-20s%6d x%4d%5d %1s   %-30s\n",fkeys[i],
  244.                 videomode[i].name,
  245.                 videomode[i].xdots,
  246.                 videomode[i].ydots,
  247.                 videomode[i].colors,
  248.                 accessmethod[videomode[i].dotmode],
  249.                 videomode[i].comment
  250.                 );
  251.             }
  252.         for (; i < j+15; i++) printf("\n");
  253. printf("    (Hit the <ENTER> key to see another page of supported Video modes) \n\n");
  254. printf("Please Select your Video Mode by hitting a Function Key (F1, F2, F3, F4,...) \n");
  255. printf("    (Notation:  F1, SF1, CF1, AF1 == Normal-, Shift-, Control- or Alt-F1) \n");
  256. printf("    'B' after #-of-colors means video access is via the BIOS (s-l-o-w-l-y)\n");
  257. printf("The program will begin with the full Mandelbrot Set as a starting point. ");
  258.         }
  259.     }
  260.  
  261. historyptr = 0;                    /* initialize history ptr */
  262. history[0][0] = -1;
  263. zoomoff = 1;                    /* zooming is enabled */
  264.  
  265. more = 1;
  266. while (more) {                    /* eternal loop */
  267.  
  268.                         /* collect adapter info */
  269.     axmode  = videomode[adapter].videomodeax; /* video mode (BIOS call) */
  270.     bxmode  = videomode[adapter].videomodebx; /* video mode (BIOS call) */
  271.     cxmode  = videomode[adapter].videomodecx; /* video mode (BIOS call) */
  272.     dxmode  = videomode[adapter].videomodecx; /* video mode (BIOS call) */
  273.     dotmode = videomode[adapter].dotmode;    /* assembler dot read/write */
  274.     xdots   = videomode[adapter].xdots;    /* # dots across the screen */
  275.     ydots   = videomode[adapter].ydots;    /* # dots down the screen   */
  276.     colors  = videomode[adapter].colors;    /* # colors available */
  277.  
  278.     xstep   = xdots / 40;            /* zoom-box increment: across */
  279.     ystep   = ydots / 40;            /* zoom-box increment: down */
  280.     if (xdots == 640 && ydots == 350)    /* zoom-box adjust:  640x350 */
  281.         { xstep = 16; ystep =  9; }
  282.     if (xdots == 720 && ydots == 512)    /* zoom-box adjust:  720x512 */
  283.         { xstep = 20; ystep = 15; }
  284.     if (xdots == 1024 && ydots == 768)    /* zoom-box adjust: 1024x768 */
  285.         { xstep = 32; ystep = 24; }
  286.  
  287.     delx = ((xmax - xmin) / (xdots - 1));    /* calculate the stepsizes */
  288.     dely = ((ymax - ymin) / (ydots - 1));
  289.  
  290.     if (delx <= 0 || dely <= 0) {        /* oops.  zoomed too far */
  291.         zoomoff = 0;
  292.         dely = 1;
  293.         delx = 1;
  294.         }
  295.  
  296.     lx0[0] = xmin;                /* fill up the x, y grids */
  297.     ly0[0] = ymax;
  298.     for (i = 1; i < xdots; i++ )
  299.         lx0[i] = lx0[i-1] + delx;
  300.     for (i = 1; i < ydots; i++ )
  301.         ly0[i] = ly0[i-1] - dely;
  302.  
  303.     if (zoomoff == 0) {
  304.         xmax = lx0[xdots-1];        /* re-set xmax and ymax */
  305.         ymin = ly0[ydots-1];
  306.         }
  307.  
  308.     if (history[0][0] == -1)            /* initialize the history file */
  309.         for (i = 0; i < MAXHISTORY; i++) {
  310.             history[i][0] = xmax;
  311.             history[i][1] = xmin;
  312.             history[i][2] = ymax;
  313.             history[i][3] = ymin;
  314.             history[i][4] = creal;
  315.             history[i][5] = cimag;
  316.         }
  317.  
  318.     if (history[historyptr][0] != xmax  ||    /* save any (new) zoom data */
  319.         history[historyptr][1] != xmin  ||
  320.         history[historyptr][2] != ymax  ||
  321.         history[historyptr][3] != ymin  ||
  322.         history[historyptr][4] != creal ||
  323.         history[historyptr][5] != cimag ) {
  324.         if (++historyptr == MAXHISTORY) historyptr = 0;
  325.         history[historyptr][0] = xmax;
  326.         history[historyptr][1] = xmin;
  327.         history[historyptr][2] = ymax;
  328.         history[historyptr][3] = ymin;
  329.         history[historyptr][4] = creal;
  330.         history[historyptr][5] = cimag;
  331.         }
  332.  
  333.     setvideomode(axmode,bxmode,cxmode,dxmode); /* switch video modes */
  334.  
  335.     if (calcdots() == 0)            /* draw the fractal */
  336.         printf("\007");            /* finished!  wake up! */
  337.  
  338.     ixmin = 0;  ixmax = xdots-1;        /* initial zoom box */
  339.     iymin = 0;  iymax = ydots-1;
  340.  
  341.     kbdmore = 1;
  342.     while (kbdmore == 1) {            /* loop through cursor keys */
  343.         kbdchar = getakey();
  344.         switch (kbdchar) {
  345.             case 32:            /* spacebar */
  346.                 if (julia == 0) {    /* switch to Julia */
  347.                     julia = 1;
  348.                     creal = (xmax + xmin) / 2;
  349.                     cimag = (ymax + ymin) / 2;
  350.                     jxmin = xmin;  jxmax = xmax;
  351.                     jymin = ymin;  jymax = ymax;
  352.                     xmax =  7;     /* xmax ==  1.75 */
  353.                      xmin = -7;     /* xmin == -1.75 */
  354.                     ymax =  7;     /* ymax ==  1.75 */
  355.                     ymin = -7;     /* ymin == -1.75 */
  356.                     xmax = xmax << (FUDGEFACTOR-2);
  357.                     xmin = xmin << (FUDGEFACTOR-2);
  358.                     ymax = ymax << (FUDGEFACTOR-2);
  359.                     ymin = ymin << (FUDGEFACTOR-2);
  360.                     }
  361.                 else    {        /* switch to Mandel */
  362.                     julia = 0;
  363.                     creal = 0;
  364.                     cimag = 0;
  365.                     xmin = jxmin;  xmax = jxmax;
  366.                     ymin = jymin;  ymax = jymax;
  367.                     }
  368.                 kbdmore = 0;
  369.                 break;
  370.             case 1071:            /* home */
  371.                 if (--historyptr < 0)
  372.                     historyptr = MAXHISTORY-1;
  373.                 xmax  = history[historyptr][0];
  374.                 xmin  = history[historyptr][1];
  375.                 ymax  = history[historyptr][2];
  376.                 ymin  = history[historyptr][3];
  377.                 creal = history[historyptr][4];
  378.                 cimag = history[historyptr][5];
  379.                 julia = 0;
  380.                 if (creal != 0 || cimag != 0) julia = 1;
  381.                 zoomoff = 1;
  382.                 kbdmore = 0;
  383.                 break;
  384.             case 9:                /* tab */
  385.                 ccreal = creal; ccreal = ccreal / fudge;
  386.                 ccimag = cimag; ccimag = ccimag / fudge;
  387.                 xxmax = xmax; xxmax = xxmax / fudge;
  388.                 xxmin = xmin; xxmin = xxmin / fudge;
  389.                 yymax = ymax; yymax = yymax / fudge;
  390.                 yymin = ymin; yymin = yymin / fudge;
  391.                 if (julia == 0 )
  392.                     printf("The Current Mandelbrot Boundaries are: \n");
  393.                 else    {
  394.                     printf("The Current Julia Set Boundaries are: \n");
  395.                     printf("    Creal = %12.9f \n",ccreal);
  396.                     printf("    Cimag = %12.9f \n",ccimag);
  397.                     }
  398.                 printf("     Xmin = %12.9f \n",xxmin);
  399.                 printf("     Xmax = %12.9f \n",xxmax);
  400.                 printf("     Ymin = %12.9f \n",yymin);
  401.                 printf("     Ymax = %12.9f \n",yymax);
  402.                 continue;
  403.                 break;
  404.             case 13:            /* Enter */
  405.             case 1079:            /* end */
  406.                 kbdmore = 0;
  407.                 break;
  408.             case 1082:            /* insert */
  409.                 goto restart;
  410.                 break;
  411.             case 1000:            /* Control-C */
  412.             case 27:            /* Escape */
  413.             case 1083:            /* delete */
  414.                 more = 0; kbdmore = 0;
  415.                 break;
  416.             case 1075:            /* cursor left */
  417.                 if (zoomoff == 1 && ixmin >= 1)
  418.                     { ixmin -= 1; ixmax -= 1; }
  419.                     break;
  420.             case 1077:            /* cursor right */
  421.                 if (zoomoff == 1 && ixmax < xdots - 1)
  422.                     { ixmin += 1; ixmax += 1; }
  423.                     break;
  424.             case 1072:            /* cursor up */
  425.                 if (zoomoff == 1 && iymin >= 1)
  426.                     { iymin -= 1; iymax -= 1; }
  427.                     break;
  428.             case 1080:            /* cursor down */
  429.                 if (zoomoff == 1 && iymax < ydots - 1)
  430.                     { iymin += 1; iymax += 1; }
  431.                     break;
  432.             case 1115:            /* Ctrl-cursor left */
  433.                 if (zoomoff == 1 && ixmin >= 5)
  434.                     { ixmin -= 5; ixmax -= 5; }
  435.                     break;
  436.             case 1116:            /* Ctrl-cursor right */
  437.                 if (zoomoff == 1 && ixmax < xdots - 5)
  438.                     { ixmin += 5; ixmax += 5; }
  439.                     break;
  440.             case 1141:            /* Ctrl-cursor up */
  441.                 if (zoomoff == 1 && iymin >= 5)
  442.                     { iymin -= 5; iymax -= 5; }
  443.                     break;
  444.             case 1145:            /* Ctrl-cursor down */
  445.                 if (zoomoff == 1 && iymax < ydots - 5)
  446.                     { iymin += 5; iymax += 5; }
  447.                     break;
  448.             case 1073:            /* page up */
  449.                 if (zoomoff == 1 
  450.                   && ixmax - ixmin > 3 * xstep
  451.                   && iymax - iymin > 3 * ystep) {
  452.                     /* 640x350 Zoom-In Klooge:  Adjust the
  453.                        Zoom-Box on the initial Zoom-In */
  454.                     if (xdots == 640 && ydots == 350
  455.                       && iymin == 0  && iymax == ydots-1) {
  456.                         iymin -= 5;
  457.                         iymax += 5;
  458.                         }
  459.                     /* 720x512 Zoom-In Klooge:  Adjust the
  460.                        Zoom-Box on the initial Zoom-In */
  461.                     if (xdots == 720 && ydots == 512
  462.                       && iymin == 0  && iymax == ydots-1) {
  463.                         iymin -= 14;
  464.                         iymax += 14;
  465.                         }
  466.                     ixmin += xstep;    ixmax -= xstep;
  467.                     iymin += ystep;    iymax -= ystep;
  468.                     }
  469.                     break;
  470.             case 1081:            /* page down */
  471.                 if (zoomoff == 1
  472.                  && ixmin >= xstep && ixmax < xdots - xstep
  473.                  && iymin >= ystep && iymax < ydots - ystep) {
  474.                     ixmin -= xstep;    ixmax += xstep;
  475.                     iymin -= ystep;    iymax += ystep;
  476.                     }
  477.                     break;
  478.             default:        /* other (maybe a valid Fn key) */
  479.                 if (kbdchar >= 1059 && kbdchar < 1069
  480.                  && kbdchar < 1059 + maxvideomode) {
  481.                     adapter = kbdchar - 1059;
  482.                     kbdmore = 0;
  483.                     }
  484.                 else if (kbdchar >= 1084 && kbdchar < 1114
  485.                  && kbdchar < 1074 + maxvideomode) {
  486.                     adapter = kbdchar - 1074;
  487.                     kbdmore = 0;
  488.                     }
  489.                 else if (kbdchar >= 1120 && kbdchar < 1130
  490.                  && kbdchar < 1080 + maxvideomode) {
  491.                     adapter = kbdchar - 1080;
  492.                     kbdmore = 0;
  493.                     }
  494.                 else
  495.                     continue;
  496.                 break;
  497.             }
  498.  
  499.         if (zoomoff == 1 && kbdmore == 1) {    /* draw a zoom box? */
  500.             xmin = lx0[ixmin];
  501.             xmax = lx0[ixmax];
  502.             ymin = ly0[iymax];
  503.             ymax = ly0[iymin];
  504.             drawbox();            /* (yup) */
  505.             }
  506.         }
  507.  
  508.     }
  509.  
  510. setvideomode(3,0,0,0);            /* all done.  return to text mode. */
  511.  
  512. }
  513.