#include "types.h" INT16 devhandle,ginhandle,savin[20],savary[66]; main () { /* example program demonstrating many features of GSS-DRIVERS*/ /* pauses for a carriage return after each frame of output*/ UINT8 cstrng[80], ch_out; INT16 j, icount, i, escsav[2], joy_stat, echo; INT16 x, xval, yval, xoff, yoff, val, info, xwidth, chw, chh; INT16 intin[5], intout[5], ywidth, itemp1, itemp2, itemp3; INT16 ptsin[5], ptsout[5], col2sav[4]; SINT16 error; STATIC INT16 colary[] = { 4,5,6,1,2,3 }; static INT16 polyx[] = { 24640,24640,24000,24960,25920,25280,25280 }; static INT16 polyy[] = { 12800,19200,19200,20800,19200,19200,12800 }; static INT16 xray[] = { 8000,11200,14400,17600,20800 }; static INT16 yray[] = { 9600,12800,16000,19200,22400 }; /* initialize i/o for newframe prompt*/ /* mouse open */ /* savin[1] - savin[10] are passed to the driver*/ savin[0] = 0; /* don't preserve aspect ratio */ savin[1] = 1; savin[2] = 1; savin[3] = 3; savin[4] = 1; savin[5] = 1; savin[6] = 1; savin[7] = 0; savin[8] = 0; savin[9] = 1; savin[10] = 1; /* prompt for paper changes */ savin[11] = 'G'; /* OPEN GIN DEVICE */ savin[12] = 'I'; savin[13] = 'N'; savin[14] = ' '; savin[15] = ' '; savin[16] = ' '; savin[17] = ' '; savin[18] = ' '; /* open the workstation and save output in savary array*/ joy_stat = v_opnwk(savin, &ginhandle, savary); /* savin[1] - savin[10] are passed to the driver*/ savin[0] = 0; /* don't preserve aspect ratio */ savin[1] = 1; savin[2] = 1; savin[3] = 3; savin[4] = 1; savin[5] = 1; savin[6] = 1; savin[7] = 0; savin[8] = 0; savin[9] = 1; savin[10] = 1; /* prompt for paper changes */ savin[11] = 'D'; /* OPEN CRT DEVICE */ savin[12] = 'I'; savin[13] = 'S'; savin[14] = 'P'; savin[15] = 'L'; savin[16] = 'A'; savin[17] = 'Y'; savin[18] = ' '; /* open the workstation and save output in savary array*/ error = v_opnwk(savin, &devhandle, savary); if (error < 0) { printf("Error %d Opening Device Display\n",vq_error()); exit (-1); } if (joy_stat < 0) ginhandle = devhandle; /* draw a box around entire display surface area*/ box (0, 0, 32767, 32767); /* set character height*/ chh = vst_height(devhandle, 800, &chw, &xwidth, &ywidth); vst_alignment(devhandle, 1, 0, &itemp1, &itemp2); /* label the output*/ v_gtext(devhandle, 16000, 26880, "VDI Test"); v_gtext(devhandle, 16000, 24640, "Graphic Software Systems"); /* set the polyline line type to type 3*/ vsl_type(devhandle, 3); /* test poly markers*/ for (i=1; i<7; i++) { /* set polymarker color index to index i*/ vsm_color(devhandle, i); /* set polymarker marker type to index i*/ vsm_type(devhandle, i); /* output markers*/ ptsin[0] = 1600; ptsin[1] = i*3200+3200; v_pmarker(devhandle, 1, ptsin); } /* change polyline type back to index 1*/ vsl_type(devhandle, 1); /* test moves and draws. grid will be output*/ for (i=1; i<=6; i++) { x = 3200*i+1600; /* set polyline line color index to i*/ vsl_color(devhandle, i); /* draw a line*/ ptsin[0] = x; ptsin[1] = 6400; ptsin[2] = x; ptsin[3] = 22400; v_pline(devhandle, 2, ptsin); /* output next line*/ ptsin[0] = 4800; ptsin[1] = x+1600; ptsin[2] = 20800; ptsin[3] = x+1600; v_pline(devhandle, 2, ptsin); } /* test poly markers*/ /* set polymarker marker type to type 6*/ vsm_type(devhandle, 6); /* set up the points array*/ j = 0; for (i=0; i<5; i++) { ptsin[j] = xray[i]; ptsin[j+1] = yray[i]; j = j+2; } /* output the markers*/ v_pmarker(devhandle, 5, ptsin); /* test draws and markers*/ /* set polyline color index to 1*/ vsl_color(devhandle, 1); /* set polymarker color index to 1*/ vsm_color(devhandle, 1); for (i=1; i<=6; i++){ /* set polymarker type */ vsm_type(devhandle, i); /* change marker size*/ vsm_height(devhandle, 500*i + 320); /* output polyline*/ val = i*3200; ptsin[0] = 4800+val; ptsin[1] = 1920; ptsin[2] = 8000+val; ptsin[3] = 1920; v_pline(devhandle, 2, ptsin); /* output a marker*/ ptsin[0] = 8000+val; ptsin[1] = 1920; v_pmarker(devhandle, 1, ptsin); } /* restore marker size*/ vsm_height(devhandle, 320); /* test line styles*/ for (i=1; i<7; i++) { /* set the polyline line type to value of i*/ vsl_color(devhandle, i); vsl_type(devhandle, i); /* output the lines*/ ptsin[0] = 4500*(i-1)+2440; ptsin[1] = 28800; ptsin[2] = 4000+ptsin[0]; ptsin[3] = 28800; v_pline(devhandle,2,ptsin); } /* reset the polyline line type to 2*/ vsl_type(devhandle, 2); vsl_color(devhandle, 1); /* test fill area*/ /* set fill area interior style to solid*/ vsf_interior(devhandle, 1); /* set fill area color index to 1*/ vsf_style(devhandle, 1); /* set up points array*/ j = 0; for (i=0; i<7; i++) { ptsin[j] = polyx[i]; ptsin[j+1] = polyy[i]; j = j+2; } /* output the filled area*/ v_fillarea(devhandle, 7, ptsin); for (i=0;i<5; i++) cstrng[i] = (UINT8) savary[i+53]; cstrng[5] = '\000'; /* nul terminate the string */ v_gtext(devhandle, 24860, 6000, cstrng); vst_alignment(devhandle, 0, 0, &itemp1, &itemp2); /* reset the polyline line type to 1*/ vsl_type(devhandle, 1); /* initiate a new frame*/ newfrm(); /* test escape functions*/ vq_chcells(devhandle, &escsav[0], &escsav[1]); if (escsav[0] != -1 && escsav[1] != -1){ /* enter cursor addressing mode*/ v_enter_cur(devhandle); /* home the cursor*/ v_curhome(devhandle); i = escsav[0]; for (j=1; j>1, escsav[1]>>1); v_eeol(devhandle); /* output prompt */ vs_curaddress(devhandle, 1, 26); v_curtext(devhandle, "Tap 'RETURN' to continue..."); waitcr(); /* move down a few lines and erase to end of screen*/ vs_curaddress(devhandle, (escsav[0]>>1)+4, escsav[1]>>1); v_eeos(devhandle); /* inquire current cursor position, save it and write more chars*/ vq_curaddress(devhandle, &escsav[0], &escsav[1]); /* output prompt */ vs_curaddress(devhandle, 1,26); v_curtext(devhandle, "Tap 'RETURN' to continue..."); waitcr(); /* home cursor and erase to end of screen*/ v_curhome(devhandle); v_eeos(devhandle); /* home cursor again*/ v_curhome(devhandle); /* output a character*/ v_curtext(devhandle, "C"); /* move to save position, output same char*/ vs_curaddress(devhandle, escsav[0], escsav[1]); v_curtext(devhandle, "C"); /* pause and prompt the user */ vs_curaddress(devhandle, 1,26); v_curtext(devhandle, "Tap `RETURN' to continue..."); waitcr(); } /* reenter graphics mode*/ v_exit_cur(devhandle); /* clear the screen */ v_clrwk(devhandle); /* set fill area color index to value of i*/ vsf_color(devhandle, 1); /* set fill area style to be solid */ vsf_interior(devhandle, 1); vswr_mode(devhandle, 4); for (j=1; j<=16; j++) { yoff = j*1600; /* output text string in replace mode*/ v_gtext(devhandle, 8000, yoff-320, "ABCabc"); /* output a bar at location specified by ptsin*/ ptsin[0] = 4800 - (chw >> 1); ptsin[1] = yoff; ptsin[2] = ptsin[0] + (chw * 3); ptsin[3] = yoff + chh; v_bar(devhandle, ptsin); /* output writing mode requested*/ sprintf(cstrng,"%d",j); v_gtext(devhandle, 1600, yoff, cstrng); /* request writing mode*/ info = vswr_mode(devhandle, j); /* output writing mode selected*/ sprintf(cstrng,"%d",info); v_gtext(devhandle, 3200, yoff, cstrng); v_gtext(devhandle, 4800, yoff, cstrng); /* output a line in writing mode selected*/ ptsin[0] = 8000; ptsin[1] = yoff; ptsin[2] = 11200; ptsin[3] = yoff; v_pline(devhandle, 2, ptsin); /* reset writing mode to replace*/ info = vswr_mode(devhandle, 4); } newfrm(); /* test bars and background color*/ /* icount is number of gdps available to driver*/ for (i=0; i<=7; i++) { /* set fill area color index to value of i*/ vsf_color(devhandle, i); /* set fill area interior style index to value of i*/ vsf_style(devhandle, i); /* set fill area style to be hollow, solid, pattern or hatch*/ vsf_interior(devhandle, i&3); /* output a bar at location specified by ptsin*/ ptsin[0] = (i+1)*3200; ptsin[1] = 1600; ptsin[2] = ptsin[0]+1600; ptsin[3] = 6400; v_bar(devhandle, ptsin); } v_arc(devhandle, 3200, 9600, 3200, 0, 900); /* set fill area interior style to 1*/ vsf_style(devhandle, 1); /* set fill area color index to 2*/ vsf_color(devhandle, 2); /* output pie slice*/ v_pieslice(devhandle, 3200, 19200, 3200, 0, 900); /* set fill area interior style to pattern*/ vsf_style(devhandle, 2); v_circle(devhandle, 12800, 19200, 3200); /* set fill area interior style to hatch*/ vsf_interior(devhandle, 2); /* set fill area hatch index to 3*/ vsf_style(devhandle, 3); v_circle(devhandle, 20800, 19200, 3200); newfrm(); /* test text rotation*/ /* set polymarker marker type to index 3*/ vsm_type(devhandle, 3); /* output a marker at the center of the screen*/ ptsin[0] = 16000; ptsin[1] = 16000; v_pmarker(devhandle, 1, ptsin); for (i=0; i<8; i++) { /* set character up vector*/ vst_rotation(devhandle, i*450); /* output text string*/ v_gtext(devhandle, 16000, 16000, " ABCabc"); } /* reset character up vector to default*/ vst_rotation(devhandle, 0); newfrm(); /* test character size and centering*/ /* output a polyline in the middle of the display surface*/ ptsin[0] = 32000; ptsin[1] = 16000; ptsin[2] = 0; ptsin[3] = 16000; v_pline(devhandle, 2, ptsin); xoff = 373; for (i=0; i<=10; i++) { vst_color(devhandle, i); /* set the character height*/ vst_height(devhandle, (i*2*320)+320, &chw, &xwidth, &ywidth); if (chw>32767 - xoff) break; /* output a character*/ v_gtext(devhandle, xoff, 16000, "A"); xoff += chw + 373; } vst_color(devhandle, 1); /* output text centered on a marker*/ /* set character height*/ vst_height(devhandle, 1600, &chw, &xwidth, &ywidth); /* set polymarker type to 5*/ vsm_type(devhandle, 5); /* output the marker*/ ptsin[0] = 16000; ptsin[1] = 10000; v_pmarker(devhandle, 1, ptsin); /* output the character*/ v_gtext(devhandle, 16000, 10000, "A"); /* reset character height*/ vst_height(devhandle, 800, &chw, &xwidth, &ywidth); newfrm(); /* test cell array*/ ptsin[0] = 12800; ptsin[1] = 6400; ptsin[2] = 19200; ptsin[3] = 12800; v_cellarray(devhandle, ptsin, 3, 3, 2, 4, colary); ptsin[0] = 12800; ptsin[1] = 12800; ptsin[2] = 19200; ptsin[3] = 19200; v_cellarray(devhandle, ptsin, 3, 3, 2, 4, colary); /* test inquire cell array*/ ptsin[0] = 12800; ptsin[1] = 12800; ptsin[2] = 19200; ptsin[3] = 19200; vq_cellarray(devhandle, ptsin, 3, 2, &itemp1, &itemp2, &itemp3, colary); newfrm(); /* if invalid values returned or device has no pixel capabilities*/ /* branch around the cell array output*/ if (itemp3 != 1 && savary[38]==1){ /* output the results of the inquiry*/ v_cellarray(devhandle, ptsin, 3, 3, 2, 4, colary); newfrm(); } /* icount is number of available line widths*/ icount = savary[7]; for (i=1; i<=icount; i++) { /* set line width*/ vsl_width(devhandle, 1280*i); /* output a line*/ ptsin[0] = 25600; ptsin[1] = 3200*i; ptsin[2] = 6400; ptsin[3] = 3200*i; v_pline(devhandle, 2, ptsin); } vsl_width(devhandle, 1); newfrm(); yoff = 25600; /* j is the number of available hardware fonts*/ j = (savary[10] < 5) ? savary[10] : 5; for (i=1; i<=j; i++) { /* set text font to value of i*/ vst_font(devhandle, i); /* output text string*/ v_gtext(devhandle, 6400, yoff, " !#$%&'()*+,-./0123456789:;<=>?ABC[]^_abc{|}~"); yoff -= 4800; } /* reset text font to value of 1*/ vst_font(devhandle, 1); newfrm(); /* test set color representation*/ /* if savary[13] is less than 3 device has only two color indices*/ if (savary[13]>=3){ vq_color(devhandle, 2, 1, col2sav); /* set color representation of index 2*/ intin[0] = 1000; intin[1] = 200; intin[2] = 0; vs_color(devhandle, 2, intin, intout); } /* set color representation of index 1*/ intin[0] = 200; intin[1] = 600; intin[2] = 200; vs_color(devhandle, 1, intin, intout); /* loop three times; the first and second times inquiring color rep*/ for (j=1; j<4; j++) { for (i=1; i<=2; i++) { /* set polyline color index for the line to the value of i*/ vsl_color(devhandle, i); /* set text color index for the line label*/ vst_color(devhandle, i); /* output line label*/ sprintf(cstrng,"%d",i); v_gtext(devhandle, 3200, 22400 -i*6400, cstrng); /* output the line*/ ptsin[0] = 6400; ptsin[1] = 16000-((i-1)*6400); ptsin[2] = 16000; ptsin[3] = 16000-((i-1)*6400); v_pline(devhandle, 2, ptsin); } newfrm(); /* inquire color representation. if third time through goto next test*/ if (j != 3){ vq_color(devhandle, 1, j-1, intout); /* set color representation with results of inquiry*/ vs_color(devhandle, vq_color(devhandle, 1, j-1, intout), intout, intout); } } /* reset color representation of index 1*/ intin[0] = 1000; intin[1] = 1000; intin[2] = 1000; vs_color(devhandle, 1, intin, intout); if (savary[13]>=3) { /* restore index 2 */ /* set color representation of index 2*/ vs_color(devhandle, 2, col2sav, intout); } /* reset color index to 1*/ vsl_color(devhandle, 1); vst_color(devhandle, 1); vsf_color(devhandle, 1); /* test gin if available*/ /* savary[40] is number of locator devices available*/ if (savary[40]!=0){ /* output prompt for locator input*/ v_gtext(devhandle, 8000, 3200, "Test GIN - Input 5 Points" ); /* input points from the device*/ xval = 16384; yval = 16384; for (i=0; i<5; i++) { ptsin[0] = xval; ptsin[1] = yval; vrq_locator(ginhandle,ptsin,(i+1)&1, i%3, devhandle, ptsout, &ch_out); xray[i] = ptsout[0]; yray[i] = ptsout[1]; xval = xray[i]; yval = yray[i]; } /* fill area defined by points just input*/ j = 0; for (i=0; i<5; i++) { ptsin[j] = xray[i]; ptsin[j+1] = yray[i]; j += 2; } v_fillarea (devhandle, 5, ptsin); newfrm(); } if (savary[42]!=0){ /* output prompt*/ v_gtext(devhandle, 6400, 16000, "Press a Function Key"); /* input choice from the device*/ vrq_choice(devhandle, 1, intout); /* output 'key=' message*/ v_gtext(devhandle, 6400, 6400, "Key = "); sprintf(cstrng,"%d",intout[0]); v_gtext(devhandle, 10000, 6400, cstrng); newfrm(); } /* savary[43] is number of string devices available*/ if (savary[43] != 0) { echo = 0; /* do this test twice; the first time echo off, second time echo on*/ for (j=1; j<=2; j++) { /* output prompt*/ v_gtext(devhandle, 6400, 16000, "Enter String: "); /* input the string from the device*/ ptsin[0] = 3200; ptsin[1] = 20000; if (vrq_string(devhandle, 80, echo, ptsin, cstrng)) { /* output the string received*/ v_gtext(devhandle, 6400, 6400, cstrng); } echo = 1; newfrm(); } } /* close the workstation*/ v_clswk(devhandle); } box(x,y,w,h) INT16 x,y,w,h; { INT16 ptsin[10]; /* use polyline to output the box*/ ptsin[0] = x; ptsin[1] = y; ptsin[2] = x+w; ptsin[3] = y; ptsin[4] = x+w; ptsin[5] = y+h; ptsin[6] = x; ptsin[7] = y+h; ptsin[8] = x; ptsin[9] = y; v_pline(devhandle, 5, ptsin); } /********************************/ newfrm() { INT16 ptsin[2]; UINT8 cstrng[80]; /* this routine outputs prompt, pauses for input, and clears workstation*/ /* upon receipt of the input*/ if (savin[10] && savary[45] == 0) { /* Do the pause if desired */ v_gtext (devhandle, 5600,30000, "Tap 'RETURN' to continue..."); /* input the string from the device*/ ptsin[0] = 0; ptsin[1] = 0; vrq_string(devhandle, 80, 0, ptsin, cstrng); } /* clear the workstation*/ v_clrwk(devhandle); } /********************************/ waitcr() { INT16 ptsin[2]; UINT8 cstrng[80]; if (savin[10]) { /* Do the pause if desired */ /* input the string from the device*/ ptsin[0] = 0; ptsin[1] = 0; vrq_string(devhandle, 80, 0, ptsin, cstrng); } }