home *** CD-ROM | disk | FTP | other *** search
- /* Program to demonstrate video graphics functions
- using NDP C-386 graphics extension library
-
- MicroWay, Inc.
- P.O. Box 79
- Kingston, MA 02364
- (508) 746-7341
- */
-
- #include <stdio.h>
- #include <math.h>
-
- #include <grex.h> /* graphic functions must be declared */
-
- int show_video_systems();
- int nint();
-
- #define nint(a) ( (((int)a) % 2 == 1) ? (int)a+0.5 : (int)a )
- #define min0(x,y) ((x < y) ? x : y)
- #define max0(x,y) ((x > y) ? x : y)
-
- main()
- {
- int i, j, k, ier;
- int mode;
- int new_mode;
- int code;
- int limx, limy, max_color;
- int xmin, xmax, ymin, ymax;
- int video_system[4];
- int ix, iy, ih, iv;
- int jx, jy, L;
- int new_color, key;
- char pal [17];
- char prompt [64], string [64];
- static char buffer [4096];
- static char text_buffer [4096];
-
- static unsigned dash_patterns [16] = {0xFFFFFFFF,0x00FFFFFF,0x0000FFFF,
- 0x000000FF,0xF0F0F0F0,0x0F0F0F0F,0xFF00FF00,0x00FF00FF,0xF00FF00F,
- 0xF6F6F6F6,0x11111111,0x33333333,0x55555555,0x77777777,0x99999999,
- 0xAAAAAAAA};
-
- printf("\nNDP C-386 Graphics Extension test program\n\n");
-
- printf("MicroWay, Inc.\nP.O. Box 79\nKingston, MA 02364\n(508) 746-7341\n\n");
-
- mode = video_configuration(video_system);
-
- printf("Video system codes: %d %d %d %d\n",video_system[0],
- video_system[1],
- video_system[2],
- video_system[3]);
-
- printf("Suggested graphic mode: %d\n",mode);
-
- while ( (new_mode = show_video_systems()) != 0)
- {
- if ( new_mode < 0)
- {
- printf ("If other than 800 horizontal pixels, enter horizontal pixel count: ");
- gets (string);
- if (strlen(string) == 0)
- {
- limx = 800;
- }
- else
- {
- sscanf (string,"%d",&limx);
- }
- printf ("If other than 600 vertical pixels, enter vertical pixel count: ");
- gets (string);
- if (strlen(string) == 0)
- {
- limy = 600;
- }
- else
- {
- sscanf (string,"%d",&limy);
- }
- new_mode = super_vga (-new_mode,limx,limy);
- ier = new_mode;
- }
- else
- {
- ier = graphics_mode (new_mode);
- }
-
- if ( ier != 0)
- {
- get_device_limits(&limx,&limy,&max_color);
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 1: Set pixels */
-
- clear();
-
- set_color(6);
-
- for (i = 100; i <= 150; i++)
- {
- j = i;
- set_pixel(i,j);
- }
-
- graphic_text("Test 1: Setting pixels",10,limy-20,14);
- graphic_text("Press a key to continue",10,limy-10,14);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 2: Draw lines */
-
- set_color(1);
-
- move(100,100);
- draw(150,100);
- draw(150,150);
- draw(100,150);
- draw(100,100);
-
- move(101,101);
- draw(149,101);
- draw(149,149);
- draw(101,149);
- draw(101,101);
-
- set_color(4);
-
- move ( 99, 99);
- draw (151, 99);
- draw (151,151);
- draw ( 99,151);
- draw ( 99, 99);
-
- move ( 98, 98);
- draw (152, 98);
- draw (152,152);
- draw ( 98,152);
- draw ( 98, 98);
-
- set_color (0);
- filled_rectangle (0, limy-20, limx, limy);
-
- graphic_text("Test 2: drawing lines",10,limy-20,14);
- graphic_text("Press a key to continue",10,limy-10,14);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 3. Circles */
-
- ix = 240;
- iy = 100;
- ih = 30 * aspect_ratio(new_mode)/100;
- iv = 30;
-
- set_color (2);
- open_ellipse (ix,iy,ih,iv);
- filled_ellipse (ix+2*ih,iy+iv,ih,iv);
-
- set_color (0);
- filled_rectangle (0, limy-20, limx, limy);
-
- graphic_text("Test 3: Circles",10,limy-20,14);
- graphic_text("Press a key to continue",10,limy-10,14);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 4: Saving and restoring windows */
-
- set_color (0);
- filled_rectangle (0,limy-30,limx,limy);
-
- graphic_text("Test 4: Saving and restoring windows",10,limy-30,14);
-
- save_window (98,98,152,152,buffer);
- restore_window (38,98,92,152,buffer);
-
- pause();
-
- strcpy (string,"Saved window; press a key to restore");
- L = strlen(string);
- ix = 19;
- iy = 120;
- jx = 25+8*L;
- jy = 131;
- save_window (ix, iy, jx, jy, buffer);
- set_color (0);
- filled_rectangle (ix, iy, jx, jy);
- set_color (11);
- move (ix,iy);
- draw (jx,iy);
- draw (jx,jy);
- draw (ix,jy);
- draw (ix,iy);
- graphic_text (string, ix+5, iy+2, 11);
- pause ();
- restore_window (ix, iy, jx, jy, buffer);
-
- graphic_text ("Move window using arrow keys", 10, limy-20, 14);
- graphic_text ("Press <Enter> to begin the next test", 10, limy-10, 14);
-
- strcpy (string,"Text window");
- L = strlen(string);
- ix = 16;
- iy = 120;
- jx = 25+8*L;
- jy = 131;
- save_window (ix, iy, jx, jy, buffer);
- set_color (0);
- filled_rectangle (ix, iy, jx, jy);
- set_color (11);
- move (ix,iy);
- draw (jx,iy);
- draw (jx,jy);
- draw (ix,jy);
- draw (ix,iy);
- graphic_text (string, ix+5, iy+2, 11);
-
- save_window (ix, iy, jx, jy, text_buffer);
- while ( (key = pause()) != 13 )
- {
- restore_window (ix, iy, jx, jy, buffer);
-
- if ( key == -71 ) {ix -= 8; iy -= 2; jx -= 8; jy -= 2;}
- if ( key == -72 ) { iy -= 2; jy -= 2;}
- if ( key == -73 ) {ix += 8; iy -= 2; jx += 8; jy -= 2;}
- if ( key == -75 ) {ix -= 8; jx -= 8; }
- if ( key == -77 ) {ix += 8; jx += 8; }
- if ( key == -79 ) {ix -= 8; iy += 2; jx -= 8; jy += 2;}
- if ( key == -80 ) { iy += 2; jy += 2;}
- if ( key == -81 ) {ix += 8; iy += 2; jx += 8; jy += 2;}
-
- if (ix < 0) {jx += 8; ix += 8;}
- if (iy < 0) {jy += 2; iy += 2;}
- if (jx > limx) {ix -= 8; jx -= 8;}
- if (jy > limy) {iy -= 2; jy -= 2;}
-
- save_window (ix, iy, jx, jy, buffer);
- restore_window (ix, iy, jx, jy, text_buffer);
- }
-
- restore_window (ix, iy, jx, jy, buffer);
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 5: Move a cursor and fill regions */
-
- set_color(0);
- filled_rectangle(10,limy-30,limx,limy);
- graphic_text("Test 5: Cursor movement and region fill",10,limy-30,14);
- graphic_text("Move cursor using arrow keys",10,limy-20,14);
- graphic_text("Press R to fill red, B = blue, G = green",10,limy-10,14);
- ix = 240;
- iy = 100;
- i = ix;
- j = iy;
- while ( (k = crawl(&i,&j)) != 13 )
- {
- if (k == 'b' || k == 'B') flood_fill (i,j,1,1);
- if (k == 'g' || k == 'G') flood_fill (i,j,2,2);
- if (k == 'r' || k == 'R') flood_fill (i,j,4,4);
- }
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 6: Cursor movement in a clipping window */
-
- set_color (0);
- filled_rectangle (10,limy-30,limx,limy);
- graphic_text("Test 6: Clipping window (Quarter-screen, centered)",10,limy-30,14);
- graphic_text ("Move cursor using arrow keys",10,limy-20,14);
- graphic_text ("Press a key to continue",10,limy-10,14);
- set_clip_limits (limx/4,limy/4,3*limx/4,3*limy/4);
- get_clip_limits (&xmin,&ymin,&xmax,&ymax);
- i = (xmin + xmax)/2;
- j = (ymin + ymax)/2;
- crawl (&i,&j);
- get_device_limits (&limx,&limy,&max_color);
- set_clip_limits (0,0,limx,limy);
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 7: Show colors available in this mode */
-
- get_clip_limits(&xmin,&ymin,&xmax,&ymax);
- k = xmin;
- for (i=0; i <= max_color; i++)
- {
- set_color(i);
- j = k+1;
- k = j + xmax/(max_color+1);
- filled_rectangle(j,ymin,k,ymax);
- }
- graphic_text("Test 7: Available colors", xmin+10, ymax-10, 15);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 8: Line clipping */
-
- clear ();
- set_color (12);
- move (-100,-100);
- draw ( 800, 100);
- draw ( 300, 500);
- draw (-100, 200);
- graphic_text ("Test 8: Clipped lines",10,limy-10,9);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 9: Graphic pages */
-
- clear();
-
- if ( graphic_page_count() > 1 )
- {
- graphic_text ("Test 9: Graphic pages", 10, limy-30, 14);
- graphic_text ("Page Zero",10,limy-20,10);
- graphic_text ("Press 1 to see page one, <Enter> to continue", 10, limy-10, 14);
- set_color (4);
- ix = limx/2;
- iy = limy/2;
- iv = limy/4;
- ih = iv * aspect_ratio(new_mode)/100;
- filled_ellipse (ix, iy, ih, iv);
-
- set_active_page (1);
- clear ();
- graphic_text ("Test 9: Graphic pages", 10, limy-30, 14);
- graphic_text ("Page One", 100, limy-20, 12);
- graphic_text ("Press 0 to see page zero, <Enter> to continue", 10, limy-10, 14);
- set_color (1);
- ix = limx/4;
- iy = limy/4;
- jx = 3*ix;
- jy = 3*iy;
- filled_rectangle (ix, iy, jx, jy);
-
- while ( ( k = pause()) != 13 )
- {
- set_display_page(k);
- }
- set_active_page(0);
- set_display_page(0);
- }
- else
- {
- graphic_text("Test 9: Graphic pages",10,limy-30,14);
- graphic_text("Only one page is available in this mode",10,limy-20,14);
- graphic_text("Press a key to continue",10,limy-10,14);
- pause();
- }
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 10: Graphic text I/O */
-
- clear ();
-
- graphic_text ("Test 10: Graphic text", 10, limy-30, 14);
- graphic_text ("Use <Backspace> to fix mistakes", 10, limy-20, 14);
- graphic_text ("Press <Enter> to continue", 10, limy-10, 14);
-
- strcpy (prompt,"Please enter your name:");
- get_string (10,0,prompt,string);
- graphic_text (string,10,10,12);
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 11: XOR functions */
-
- clear();
-
- graphic_text("Test 11: XOR functions", 10, limy-20, 14);
- graphic_text("Press any key to continue", 10, limy-10, 14);
-
- ix = 0;
- iy = 0;
- jx = limx/2;
- jy = limy/2;
-
- set_color (1);
- filled_rectangle (ix, iy, jx, jy);
-
- pause();
-
- ix = limx/4;
- iy = limy/4;
- jx = 3*ix;
- jy = 3*iy;
-
- set_color (2);
- set_xor (1);
- filled_rectangle (ix, iy, jx, jy);
- set_xor (0);
-
- pause();
-
- ix = 0;
- iy = 0;
-
- set_color (4);
- set_xor (1);
- move (ix, iy);
- draw (jx, jy);
- set_xor (0);
-
- pause();
-
- ix = limx/4 - 40;
- iy = limy/2 - 8;
-
- set_xor (1);
- graphic_text("MicroWay GREX library supports XOR",ix,iy,15);
- set_xor (0);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 12: Vertical text */
-
- clear();
-
- ix = limx/8;
- iy = 7 * limy/8;
-
- vertical_text ("MicroWay GREX", ix, iy, 12);
- vertical_text ("does vertical text", ix+10, iy, 12);
-
- graphic_text ("Test 12: Vertical text and magnification", 10, limy-20, 14);
- graphic_text ("Press any key to continue", 10, limy-10, 14);
-
- magnify_text (1,1);
- ix = 10;
- iy = limy/4;
- graphic_text ("Normal graphic text",ix,iy,7);
- magnify_text (2,1);
- iy += 20;
- graphic_text ("Double-width graphic text",ix,iy,14);
- graphic_text ("Double-width graphic text",ix+1,iy,14);
- magnify_text (1,2);
- iy += 20;
- graphic_text ("Double-height graphic text",ix,iy,14);
- graphic_text ("Double-height graphic text",ix,iy+1,14);
- magnify_text (2,2);
- iy += 20;
- graphic_text ("Double-size graphic text",ix ,iy ,14);
- graphic_text ("Double-size graphic text",ix+1,iy ,14);
- graphic_text ("Double-size graphic text",ix ,iy+1,14);
- graphic_text ("Double-size graphic text",ix+1,iy+1,14);
- iy += 20;
- graphic_text ("Double-size graphic text",ix ,iy ,14);
-
- magnify_text (1,1);
- ix = 2*limx/3;
- iy = limy-10;
- vertical_text ("Normal vertical text",ix,iy,7);
- magnify_text (2,1);
- ix += 20;
- vertical_text ("Double-width vertical text",ix,iy ,14);
- vertical_text ("Double-width vertical text",ix,iy+1,14);
- magnify_text (1,2);
- ix += 20;
- vertical_text ("Double-height vertical text",ix ,iy,14);
- vertical_text ("Double-height vertical text",ix+1,iy,14);
- magnify_text (2,2);
- ix += 20;
- vertical_text ("Double-size vertical text",ix ,iy ,14);
- vertical_text ("Double-size vertical text",ix+1,iy ,14);
- vertical_text ("Double-size vertical text",ix ,iy+1,14);
- vertical_text ("Double-size vertical text",ix+1,iy+1,14);
- ix += 20;
- vertical_text ("Double-size vertical text",ix ,iy ,14);
- magnify_text(1,1);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 13: dashed lines */
-
- clear();
-
- graphic_text("Test 13: dashed lines",10,limy-20,14);
- graphic_text("Press any key to begin next test",10,limy-10,14);
-
- ix = 0;
- iy = 0;
-
- for (i=0; i < 16; i++)
- {
- move (ix,iy);
- set_color (i+1);
- set_dash (dash_patterns[i]);
- jx = limx;
- jy = i*limy/8;
- draw (jx,jy);
- }
-
- set_dash (-1);
-
- pause();
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 14: define_color */
-
- clear();
-
- graphic_text("Test 14: define_color function",10,limy-20,14);
-
- graphic_text("Press <Esc> to begin next test",10,limy-10,14);
-
- if (new_mode == 64 || max_color > 15)
- {
- set_color (0);
- filled_rectangle (10, limy-10, limx, limy);
- graphic_text ("Not supported in this mode", 10, limy-10, 14);
- pause ();
- }
- else
- {
- ix = limx/4;
- iy = limy/4;
- jx = 3 * ix;
- jy = 3 * iy;
-
- set_color (1);
- filled_rectangle (ix, iy, jx, jy);
-
- iy = jy+3;
- graphic_text ("Enter new color code: ", ix, iy, 15);
- key = 0;
- while (key != 27)
- {
- ix = limx/4 + 23 * 8;
- j = 0;
- string [0] = 0;
- new_color = 1;
- while ( (key = pause()) != 13)
- {
- if (key == 27) break;
- if (key == 8)
- {
- if (j > 0)
- {
- ix -= 8;
- j--;
- set_xor (1);
- graphic_text ( & string [j], ix, iy, 12 );
- set_xor (0);
- string [j] = 0;
- }
- }
- /* enter only numbers, not letters */
- if ( key > 47 && key < 58 )
- {
- if (j < 64) /* maximum length of string */
- {
- string [j] = key;
- string [j+1] = 0;
- graphic_text ( & string [j], ix, iy, 12 );
- ix += 8;
- j++;
- }
- }
- }
- /* read the number from string using sscanf */
- sscanf ( string, "%d", &new_color );
- define_color (1, new_color);
- ix = limx/4 + 23 * 8;
- set_xor (1);
- graphic_text (string,ix,iy,12);
- set_xor (0);
- }
- }
-
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* Test 15: set_palette */
-
- clear ();
-
- if (new_mode == 64 || max_color > 15)
- {
- graphic_text ("Test 15: set_palette function", 10, limy-30, 14 );
- graphic_text ("not available in this mode", 10, limy-20, 14 );
- graphic_text ("Press a key to continue", 10, limy-10, 14 );
- pause();
- }
- else
- {
- key = 0;
- while ( key != 27)
- {
- ix = limx/5; /* draw a bunch of bars of different colors */
- iy = limy/5;
- jx = 4 * ix;
- jy = 4 * iy - 10;
-
- k = ix;
- for (i=0; i < max_color+1 ; i++)
- {
- set_color ( i );
- j = k+1;
- k = j + (jx-ix)/(max_color+1);
- filled_rectangle ( j, iy, k, jy );
- }
-
- ix = 10; /* write numbers on the screen edge */
- for (i=0; i < 17; i++)
- {
- pal [i] = 0;
- iy = 10 * (i+1);
- sprintf (string,"%2d\0",i);
- graphic_text (string, ix, iy, 11 );
- }
-
- graphic_text ("Test 15: set_palette function", 60, limy-50, 14 );
- graphic_text ("Select a new color value for each palette register", 60, limy-40, 14 );
- graphic_text ("use <Backspace> to correct, <Enter> to move to next value.", 60, limy-30, 14 );
- graphic_text ("The new palette will be set after you complete the list.", 60, limy-20, 14 );
- graphic_text (">> Press <Esc> to move on to the next test", 60, limy-10, 14 );
-
- i = 0; /* i is the palette register number */
- iy = 10;
- while ( i < 17) /* there are 16, and also the overscan */
- {
- ix = 35;
- graphic_text ( "\020", 0, iy, 12 ); /* place arrow */
-
- j = 0; /* j is the digit counter */
- strcpy (string," ");
- while ( (key = pause()) != 13) /* until user hits Enter */
- {
- if (key == 27) break; /* or Escape */
-
- if (key == 8) /* on backspace, delete left */
- {
- if (j > 0) /* if there is a character to delete */
- {
- ix -= 8;
- j--;
- set_xor (1);
- graphic_text ( & string [j], ix, iy, 12 );
- set_xor (0);
- string [j] = 0;
- }
- }
- /* enter only numbers, not letters */
- if ( key > 47 && key < 58 )
- {
- if (j < 64) /* maximum length of string */
- {
- string [j] = key;
- string [j+1] = 0;
- graphic_text ( & string [j], ix, iy, 12 );
- ix += 8;
- j++;
- }
- }
- }
- if (key == 27) break;
-
- /* read the number from string using sscanf */
- sscanf ( string, "%d", &new_color );
- pal [i] = new_color; /* store as character */
- iy += 10; /* move to next position */
- i++; /* increment palette register counter */
- set_xor(1);
- graphic_text ("\020", 0, iy-10, 12 ); /* erase arrow */
- set_xor(0);
- }
- set_palette (pal); /* after all registers have been entered */
- clear (); /* set palette and clear screen */
- }
- }
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- /* End of tests. Return to text mode. */
-
- text_mode();
- }
- }
- }
-
- show_video_systems()
- {
- int video_system[4];
- int mode;
- int card,crt;
- int new_mode;
- char *number;
- char buffer[8];
-
- mode = video_configuration(&video_system[0]);
-
- printf("\nAvailable video systems:\n");
-
- card = video_system[0];
- crt = video_system[1];
- if (card == 0)
- {
- printf("No video adapter present\n");
- return (0);
- }
- printf("Active: ");
- if (card == 1) printf("MDA: Monochrome Display Adapter");
- if (card == 2) printf("CGA: Color Graphics Adapter");
- if (card == 3) printf("EGA: Enhanced Graphics Adapter");
- if (card == 4) printf("MCGA: Multi Color Gate Array");
- if (card == 5) printf("VGA: Video Graphics Array");
- if (card == 64) printf("HGC: Hercules Graphics Card");
-
- if (crt == 1) printf(" with MDA-compatible monochrome display\n");
- if (crt == 2) printf(" with CGA-compatible color display\n");
- if (crt == 3) printf(" with EGA-compatible color display\n");
- if (crt == 4) printf(" with PS/2-compatible monochrome display\n");
- if (crt == 5) printf(" with PS/2-compatible color display\n");
-
- card = video_system[2];
- crt = video_system[3];
- printf("Inactive: ");
-
- if (card == 0) printf("Not installed\n");
-
- if (card == 1) printf("MDA: Monochrome Display Adapter");
- if (card == 2) printf("CGA: Color Graphics Adapter");
- if (card == 3) printf("EGA: Enhanced Graphics Adapter");
- if (card == 4) printf("MCGA: Multi Color Gate Array");
- if (card == 5) printf("VGA: Video Graphics Array");
- if (card == 64) printf("HGC: Hercules Graphics Card");
-
- if (crt == 1) printf(" with MDA-compatible monochrome display\n");
- if (crt == 2) printf(" with CGA-compatible color display\n");
- if (crt == 3) printf(" with EGA-compatible color display\n");
- if (crt == 4) printf(" with PS/2-compatible monochrome display\n");
- if (crt == 5) printf(" with PS/2-compatible color display\n");
-
- printf ("\nEnter requested video mode (press <Enter> to quit): ");
- number = gets (buffer);
- new_mode = 0;
- sscanf (number,"%d",&new_mode);
- return (new_mode);
- }
-
- int crawl(x,y)
- int *x,*y;
- {
- int xmin,ymin,xmax,ymax;
- int k,j,step;
- int ix,iy,jx,jy;
- char cv[16];
- get_clip_limits(&xmin,&ymin,&xmax,&ymax);
- ix = xmax - 98;
- jx = xmax - 2;
- iy = ymax - 10;
- jy = ymax - 2;
- step = 4;
-
- move_cursor(*x,*y);
- j = get_pixel(*x,*y);
- sprintf(cv," %d %d %d",*x,*y,j);
- set_color(0);
- filled_rectangle(ix,iy,jx,jy);
- graphic_text(cv,ix,iy,9);
- k = pause();
-
- while (k < 0)
- {
- k = -k;
- if(k == 83) step = step-1;
- if(k == 82) step = step+1;
- step = max0(step,1);
- step = min0(step,100);
-
- if(k == 71 || k == 72 || k == 73) *y = *y - step;
- if(k == 79 || k == 80 || k == 81) *y = *y + step;
- if(k == 71 || k == 75 || k == 79) *x = *x - step;
- if(k == 73 || k == 77 || k == 81) *x = *x + step;
-
- if(*x < xmin) *x = xmax + *x - xmin + 1;
- if(*y < ymin) *y = ymax + *y - ymin + 1;
- if(*x > xmax) *x = xmax - *x + xmin + 1;
- if(*y > ymax) *y = ymax - *y + ymin + 1;
-
- move_cursor(*x,*y);
- j = get_pixel(*x,*y);
- sprintf(cv," %d %d %d",*x,*y,j);
- set_color(0);
- filled_rectangle(ix,iy,jx,jy);
- graphic_text(cv,ix,iy,9);
- k = pause();
- }
-
- move_cursor(-1,-1);
- set_color(0);
- filled_rectangle(ix,iy,jx,jy);
- return (k);
- }
-
- get_string (x,y,prompt,string)
- int x,y;
- char prompt [], string [];
- {
-
- /*
- Routine to get a string from the user interactively, displaying
- the results on screen, and allowing the user to backspace over
- mistakes. Return or line feed terminate the procedure. */
-
- int ix,iy,key,ic,ier;
- int xmin,ymin,xmax,ymax;
- char letter [2];
-
- letter [0] = 0;
- letter [1] = 0;
-
- ix = x;
- iy = y;
- graphic_text(prompt,ix,iy,14);
-
- ix += 8 * (1 + strlen(prompt) );
-
- get_clip_limits (&xmin,&ymin,&xmax,&ymax);
- ix = min0 (ix,xmax);
-
- string [0] = 0;
- ic = 0;
-
- while ( ( (key = pause()) != 13) && (key != 10) )
- {
- if (key > 0)
- {
- if (key == 8)
- {
- if (ic > 0)
- {
- ix -= 8;
- ic--;
- letter [0] = string [ic];
- set_xor (1);
- graphic_text (letter,ix,iy,10);
- set_xor (0);
- string [ic] = 0;
- }
- }
- if (key != 8)
- {
- letter [0] = key;
- graphic_text (letter,ix,iy,10);
- ix += 8;
- string [ic] = key;
- ic++;
- ic = min0 (ic,63);
- string [ic] = 0;
- }
- }
- }
- }