home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / telecomm / ig217src / ig217.c next >
Encoding:
C/C++ Source or Header  |  1992-04-19  |  101.0 KB  |  3,731 lines

  1.  
  2.  
  3.  
  4. /*              Instant Graphics! terminal accessory version 2.17
  5.                         Copyright 1988-92 by Larry G. Mears
  6.                            All rights reserved.
  7.                            Written with Laser C
  8.  
  9. Source Code use Agreement:
  10.  
  11.  
  12.                                                                   4-19-92
  13.  
  14.     The time has come to make this available.   If you use my IG 2.17 code
  15. in any form or fashion, be it direct or intellectial property wise in your
  16. works you must mention that you used the Instant Graphics! source by
  17. Larry G. Mears in your documentation and somewhere in your program if it
  18. shows credits.  Also any work that you do that involved the Instant Graphics
  19. source I would like for you to send me a free "registered"
  20. or comercial version of your working program/product to me for my own use.
  21. There are no other strings attached.
  22.  
  23. Mailing address:
  24.  
  25. Larry Mears
  26. 11027 Crestfield Dr.
  27. Huntsville, AL 35803
  28. USA
  29.   
  30.  
  31. BTW the biosmwc.h is really bios.h from Mark Williams C
  32. It's copyrighted so I couldn't include it.   You also need
  33. to get GIST the GI Sound Tool and from the ALCYON folder you
  34. need SNDINIT.O and SNDSUBS.O to link in for the sound effects.
  35. I have been compiling this code with Laser C v1.1
  36. */
  37.  
  38. #include <biosmwc.h>
  39. #include <peekpoke.h>
  40. #include <obdefs.h>      
  41. #include <gemdefs.h>     
  42. #include <osbind.h>
  43. #include <gembind.h>
  44. #include <portab.h>
  45. #include <linea.h>
  46.  
  47. /* DEFINES */
  48.  
  49. #define TRUE 1
  50. #define FALSE 0
  51. #define CON 2
  52. #define AUX 1
  53. #define CLK_TCK 200
  54.  
  55. /* EXTERNALS */
  56.  
  57. extern int    gl_apid;
  58. extern snd_on(),snd_off(),install_int(),remove_int(),init_snds(),
  59.        stop_snd();
  60.  
  61. /* GLOBAL VARIABLES */
  62.  
  63. int    menu_id ;    /* our menu id */
  64. int handle;        /* virtual workstation handle */
  65. int    msgbuff[8];    /* event message buffer */
  66. int    keycode;    /* keycode returned by event-keyboard */
  67. int    ret;        /* dummy return variable */
  68. int    mx,my;        /* mouse x and y pos. */
  69. int    butdown;    /* button state tested for, UP/DOWN */
  70. int    hidden;        /* current state of cursor */
  71. int    contrl[12];
  72. int    intin[128];
  73. int    ptsin[128];
  74. int    intout[128];
  75. int    ptsout[128];    /* storage wasted for idiotic bindings */
  76.  
  77. int work_in[12];    /* Input to GSX parameter array */
  78. int work_out[57];    /* Output from GSX parameter array */
  79. int pxyarray[10];    /* input point array */
  80. int lines[4];        /* for lines points drawto */
  81. int g_s=0, g_res;        /* graphics scaling flag */
  82. int rnd_f=0, rnd_t=199, r_lp=0;        /* random range */
  83.  
  84. /*LooP command Globals*/
  85. int lp1,lp2,lp3,lp4,lp5,lp_flg=0, lp_effect[2049], lp_2nd, lp_was; lp_com;
  86. int lp_eff_ct=0, lp_num_prams, lp_x, lp_1st, lp_type, lp_no_prams,
  87.     bad_cmd=0;
  88.  
  89. /* point & click vars */
  90. char r_but_tran[82]; /* string tran'ed at right button click 
  91.                         [0]=len, 81=CR FLAG */
  92. char x_r_but=0; /* right mouse button string tran flag*/
  93. char zone_cmds[48][81]; /* command string associated with each zone */
  94. int zone[48][4]; /* zone ID and zone rect defines */
  95. int zone_loopback=0;
  96.  
  97. /* file storage & misc varibles */
  98. unsigned char filename[512];
  99. unsigned char filebuffer[4096], ig_midi[10001],
  100.      mem_key[129], mem_key_cr, mem_key_flg=0;
  101. unsigned long int file_length, bytes_read, bytes_left,
  102.          bytes_parsed, num_bytes, f_ct;
  103. int filehandle, help, midi_len=0, w_1st_pass=0, mem_key_ct=0;
  104. int x_on=1, x_times=1, x_times_x=1;
  105. char f_key, midi_on=1, mouse_CR=0, des_backsp=0;
  106. unsigned char x_on_char=17, x_off_char=19;
  107.  
  108.  
  109. /* storage for "WRITTEN" text */
  110. unsigned char text[132]="  Glory to the Lord Jesus Christ!  \0";
  111.  
  112.  
  113. /* storage for screen */
  114. struct
  115.     {
  116.         int *image;
  117.         int width;
  118.         int height;
  119.         int wordw;
  120.         int flag;
  121.         int planes;
  122.         int r1,r2,r3;
  123.     } sourceMFDB, destMFDB;
  124. int      bitblt_storage[16640], vd1,vd2,vd3,vd4;   /* allow whole screen */
  125. int   original_rez, r_lock=0;
  126. int   org_color[16] [3];
  127. int   sys_color[16] [3] = { 
  128.         { 1000,1000,1000 },
  129.         { 0,0,0 },
  130.         { 1000,0,0 },
  131.         { 0,1000,0 },
  132.         { 0,0,1000 },
  133.         { 0,1000,1000 },
  134.         { 1000,1000,0 },
  135.         { 1000,0,1000 },
  136.         { 714,571,857 },
  137.         { 714,428,285 },
  138.         { 1000,571,428 },
  139.         { 0,571,428 },
  140.         { 428,428,428 },
  141.         { 571,571,571 },
  142.         { 714,714,714 },
  143.         { 857,857,857 }
  144.       };
  145.  
  146. /* storage for attributes restore */
  147. int     polym_sets[4], m_bar[800],
  148.     line_sets[6], fill_sets[4],
  149.     text_sets[10];
  150.  
  151. int snd_patches[20][56];  /* To hold data below for restoring snd 
  152.                              patches for GIST */
  153. /*  Data for GIST sounds */
  154. int only_1st_time=0;
  155. int landing[] =
  156. {
  157.     700, 78, -1, 15, 1, 0, 24576, -1,
  158.     -1229, 0, 0, -1, -9830, 0, 0, 0,
  159.     0, 0, 1, -3072, -16384, -3072, -16384, 10,
  160.     -9706, 1052, 30787, 0, -1848, 5644, -25803, 3612,
  161.     -29621, 3612, -29621, -2374, -17340, -1519, 7252, 0,
  162.     0, 0, 0, 0, 0, 0, 0, 0,
  163.     0, 0, 0, 0, 0, 0, 0, 0
  164. };
  165.  
  166. int aa[] =
  167. {
  168.     28, 477, -1, 15, 1, 1, 4681, -5,
  169.     27853, 5, -9830, -1, -1278, 7, -32768, 7,
  170.     -32768, 14, 1, -4080, -256, -4080, -256, 0,
  171.     0, -4080, -256, 18, -30086, 1696, 13405, -1200,
  172.     -26066, 1696, 13405, -1200, -26066, -1200, -26066, 0,
  173.     0, 0, 0, 0, 0, 0, 0, 0,
  174.     0, 0, 0, 0, 0, 0, 0, 0
  175. }; 
  176. int ab[] =
  177. {
  178.     200, 477, -1, 15, 1, 15, 0, -1,
  179.     -1267, 10, 3277, -1, -2573, 0, 0, 0,
  180.     0, 0, 0, 0, 0, 0, 0, 0,
  181.     0, 0, 0, 0, 0, 86, 2926, -8,
  182.     27220, 7, -16776, -85, -17949, -8, 27220, 0,
  183.     0, 0, 0, 0, 0, 0, 0, 0,
  184.     0, 0, 0, 0, 0, 0, 0, 0
  185. }; 
  186. int ac[] =
  187. {
  188.     8, 1250, 31, 15, 1, 3, -16384, -1,
  189.     -7562, 0, 0, -1, -10923, 0, 0, 1,
  190.     19988, 0, 1, -4080, -256, -4080, -256, 114,
  191.     -4444, -57, -24712, 56, 24712, 0, 0, -3584,
  192.     -8192, 28665, 0, 0, 0, -3584, -8192, 0,
  193.     1, -3, -14043, -31, 0, 31, 0, 0,
  194.     0, 1, -29491, 0, 0, 0, 0, 0
  195. }; 
  196. int ad[] =
  197. {
  198.     8, 284, -1, 15, 1, 3, -16384, -1,
  199.     -8192, 0, 0, -1, -8937, 0, 0, 0,
  200.     0, 0, 1, -4057, 2971, -4057, 2971, 338,
  201.     5214, 0, 0, 4056, -2971, 28665, 0, -8,
  202.     -10895, 57, 21627, -3584, -8192, -8, -10895, 0,
  203.     0, 0, 0, 0, 0, 0, 0, 0,
  204.     0, 0, 0, 0, 0, 0, 0, 0
  205. }; 
  206. int ae[] =
  207. {
  208.     8, 625, -1, 15, 1, 3, -16384, -1,
  209.     -32768, 0, 0, -1, -10923, 5, -19661, 5,
  210.     -19661, 0, 1, -594, -20719, -2374, -17340, 1186,
  211.     -24098, 0, 0, 2373, 17340, 0, 0, 0,
  212.     0, 0, 0, 0, 0, 0, 0, 0,
  213.     0, 0, 0, 0, 0, 0, 0, 0,
  214.     0, 0, 0, 0, 0, 0, 0, 0
  215. }; 
  216. int af[] =
  217. {
  218.     500, 477, 16, 15, 1, 0, 17873, 0,
  219.     0, 15, 0, -1, -410, 1, -22938, 0,
  220.     -30933, 0, 1, 12, -28542, 1696, 13405, -13,
  221.     18541, -2374, -17340, 0, -26652, 448, -20514, -170,
  222.     10530, 188, 29395, -405, -24861, -170, 10530, 0,
  223.     1, -1, -25395, -31, 0, 0, 3694, 31,
  224.     0, -1, -4515, 0, 0, -9, -31562, 0
  225. }; 
  226. int ag[] =
  227. {
  228.     200, 477, 31, 15, 1, 15, 0, -1,
  229.     -1267, 10, 3277, -1, -2573, 0, 0, 0,
  230.     0, 0, 1, -9, 18470, -140, -32161, 0,
  231.     5504, 28, 31652, 0, 3679, 1656, 13223, 430,
  232.     -25398, 430, -25398, -1180, -16857, -307, 25764, 0,
  233.     0, 0, 0, 0, 0, 0, 0, 0,
  234.     0, 0, 0, 0, 0, 0, 0, 0
  235. }; 
  236. int ah[] =
  237. {
  238.     40, 477, -1, 15, 1, 5, 0, -1,
  239.     -1248, 10, 3277, -1, -2533, 0, 0, 0,
  240.     0, 0, 1, -9, 18470, -140, -32161, 0,
  241.     2270, -57, -24712, -1, -3337, 1656, 13223, 430,
  242.     -25398, 430, -25398, -1180, -16857, -307, 25764, 0,
  243.     0, 0, 0, 0, 0, 0, 0, 0,
  244.     0, 0, 0, 0, 0, 0, 0, 0
  245. }; 
  246. int ai[] =
  247. {
  248.     20, 52, -1, 15, 1, 15, 0, -1,
  249.     -9830, 12, 0, -1, -1024, 1, -32768, 0,
  250.     9830, 160, 1, -28, 360, -112, 1442, 3,
  251.     31133, -57, -24712, 0, -11989, 57, 10752, -6,
  252.     23743, 5, -18586, -57, -24712, -6, 23743, 4,
  253.     0, 0, 0, 0, 0, 0, 0, 0,
  254.     0, 0, 0, 0, 0, 0, 0, 0
  255. }; 
  256. int aj[] =
  257. {
  258.     100, 477, -1, 15, 1, 3, -16384, -1,
  259.     -4572, 12, 0, -1, -1966, 1, -32768, 0,
  260.     7864, 0, 1, -4080, -256, -4080, -256, 10,
  261.     12944, 0, 0, 10, 12944, 293, -5746, -264,
  262.     -17086, 282, 10212, -275, -15067, -264, -17086, 40,
  263.     0, 0, 0, 0, 0, 0, 0, 0,
  264.     0, 0, 0, 0, 0, 0, 0, 0
  265. }; 
  266. int ak[] =  /* radio broadcast */
  267. {
  268.     800, 954, 23, 15, 1, 0, -32768, -1,
  269.     -69, 14, 6554, -15, -6554, 7, 22938, 5,
  270.     19137, 0, 1, -30, -20744, -3665, 28433, 0,
  271.     5618, -3584, -8192, 0, -26399, 10977, -21383, -72,
  272.     27596, 263, 30420, -2983, -29831, -72, 27596, 30,
  273.     1, 1, -9175, 29, -15729, -2, 17302, -31,
  274.     0, 0, 15049, 15, -32768, -4, -6554, 145
  275. };
  276. int al[] =  /* bounce ball  */
  277. {
  278.     8, 284, -1, 15, 1, 3, -16384, -1,
  279.     -8192, 0, 0, -1, -8937, 0, 0, 0,
  280.     0, 0, 1, -4057, 2971, -4057, 2971, 338,
  281.     5214, 0, 0, 4056, -2971, 28665, 0, -8,
  282.     -10895, 57, 21627, -3584, -8192, -8, -10895, 0,
  283.     0, 0, 0, 0, 0, 0, 0, 0,
  284.     0, 0, 0, 0, 0, 0, 0, 0
  285. };
  286. int am[] =  /* eerie sound */
  287. {
  288.     200, 477, -1, 15, 1, 0, -13797, -1,
  289.     26214, 14, 26214, -1, -16852, 0, 0, 0,
  290.     0, 0, 0, -4, 30423, -29, -18758, 5,
  291.     -22463, 0, 0, 28, 18758, 86, 2926, -11,
  292.     -7397, 10, 21323, -85, -17949, -11, -7397, 50,
  293.     0, 0, 0, 0, 0, 0, 0, 0,
  294.     0, 0, 0, 0, 0, 0, 0, 0
  295. };
  296. int an[] =  /* harley motorcycle */
  297. {
  298.     500, 1923, 15, 15, 1, 0, 15124, -1,
  299.     -21, 14, -29491, -15, 29491, 7, -32768, 2,
  300.     26214, 0, 1, 0, 0, 0, 0, 0,
  301.     0, 0, 0, 0, 0, 5644, -25803, -1899,
  302.     25450, 4515, -20642, -2374, -17340, -1899, 25450, 0,
  303.     1, 0, 0, 0, 0, 0, 0, 0,
  304.     0, 0, 0, 9, -5243, -6, 3146, 0
  305. };
  306. int ao[] =  /* helicopter  */
  307. {
  308.     500, 62, 15, 15, 1, 0, 15124, -1,
  309.     -21, 14, -29491, -15, 29491, 2, 6554, 0,
  310.     -27001, 0, 1, 0, 0, 0, 0, 0,
  311.     0, 0, 0, 0, 0, 12285, 0, -738,
  312.     -6554, 2948, 26214, -3072, -16384, -738, -6554, 0,
  313.     1, 0, 0, 0, 0, 0, 0, 0,
  314.     0, 0, 0, 9, -5243, -6, 3146, 0
  315. };
  316. int ap[] =  /* steam locomotive */
  317. {
  318.     800, -1, 23, 15, 1, 0, 9362, -1,
  319.     -93, 12, 29491, -1, -136, 7, 13107, 1,
  320.     25061, 0, 0, 0, 0, 0, 0, 0,
  321.     0, 0, 0, 0, 0, 0, 0, 0,
  322.     0, 0, 0, 0, 0, 0, 0, 0,
  323.     1, 1, -9175, 29, -15729, -2, 17302, -31,
  324.     0, 0, 15049, 15, -32768, -4, -6554, 145
  325. };
  326. int aq[] =  /* nice wave sound  */
  327. {
  328.     400, 238, -1, 15, 1, 0, 16384, -1,
  329.     -337, 14, 6554, -1, -154, 5, -9830, 1,
  330.     -23724, 15, 1, -300, 9867, -1200, -26066, 86,
  331.     3191, -167, 12227, 0, 1822, 12285, 0, -7,
  332.     -9339, 24, -28180, -3072, -16384, -7, -9339, 40,
  333.     0, 0, 0, 0, 0, 0, 0, 0,
  334.     0, 0, 0, 0, 0, 0, 0, 0
  335. };
  336. int ar[] =  /* robot walk */
  337. {
  338.     8, 1330, -1, 15, 1, 3, -16384, -1,
  339.     -8192, 0, 0, -1, -8937, 0, 0, 0,
  340.     0, 0, 1, -4057, 2971, -4057, 2971, 338,
  341.     5214, 0, 0, 4056, -2971, 28665, 0, -3584,
  342.     -8192, 28665, 0, -3584, -8192, -3584, -8192, 0,
  343.     1, 0, 0, 0, 0, 0, 0, 0,
  344.     0, 0, 0, 0, 0, 0, 0, 0
  345. };
  346. int as[] =  /* passing plane  */
  347. {
  348.     50, 477, -1, 15, 1, 0, 24576, -1,
  349.     -2048, 11, 16384, -1, -2633, 0, 0, 0,
  350.     0, 0, 1, -582, -10279, -4069, -6415, 54,
  351.     25814, -1077, -28428, 4, 9184, 28665, 0, -1577,
  352.     27853, 12612, -26214, -3584, -8192, -1577, 27853, 0,
  353.     0, 0, 0, 0, 0, 0, 0, 0,
  354.     0, 0, 0, 0, 0, 0, 0, 0
  355. };
  356.  
  357.  
  358.  
  359. /*  GSX UTILITY ROUTINES */
  360.  
  361. hide_mouse()
  362. {
  363.     if(! hidden){
  364.         graf_mouse(M_OFF,0x0L);
  365.         hidden=TRUE;
  366.     }
  367. }
  368.     
  369. show_mouse()
  370. {
  371.     if(hidden){
  372.         graf_mouse(M_ON,0x0L);
  373.         hidden=FALSE;
  374.     }
  375. }
  376.  
  377.  
  378. /* open virtual workstation */
  379. open_vwork()
  380. {
  381. int i, nul;
  382.     for(i=0, work_in[10]=2; i<10; work_in[i++]=1);
  383.     handle = graf_handle(&nul, &nul, &nul, &nul);
  384.     v_opnvwk(work_in,&handle,work_out);
  385.     /*v_clrwk(handle);*/
  386. }
  387.  
  388.  
  389. /* set clipping rectangle */
  390. set_clip(x,y,w,h)
  391. int x,y,w,h;
  392. {
  393. int clip[4];
  394.     clip[0]=x;
  395.     clip[1]=y;
  396.     clip[2]=x+w;
  397.     clip[3]=y+h;
  398.     vs_clip(handle,1,clip);
  399. }
  400.  
  401.  
  402.  
  403. /* Accessory Init. Until First Event_Multi */
  404. main()
  405. {
  406.  
  407.     appl_init();
  408.     menu_id=menu_register(gl_apid,"  IG 2.17  ");
  409.     original_rez=Getrez();
  410.     multi(); 
  411. }
  412.  
  413.  
  414.  
  415. /* dispatches GEM accessory tasks */
  416. multi()
  417. {
  418. int event;
  419.  
  420.       while (TRUE) {
  421.  
  422.      event = evnt_multi(MU_MESAG,
  423.             1,1,butdown,
  424.             0,0,0,0,0,
  425.             0,0,0,0,0,
  426.             msgbuff,0,0,&mx,&my,&ret,&ret,&keycode,&ret);
  427.  
  428.  
  429.  
  430.     if (event & MU_MESAG)
  431.         switch (msgbuff[0]) {
  432.  
  433.         case AC_CLOSE:
  434.              v_clsvwk(handle);
  435.             appl_exit();
  436.         break;
  437.  
  438.  
  439.         case AC_OPEN:
  440.             if (msgbuff[4] == menu_id)
  441.                   user_main();
  442.         break;
  443.         }
  444.  
  445.  
  446.       }
  447.  /* while (TRUE) */
  448.  
  449. }
  450.  
  451.  
  452. user_main() {
  453.  
  454. register long key;
  455. int flag1,g_on, reg, a, b, plex, res;
  456. int line[4], r_row,r_column,snd_num,snd_ele;
  457. char *oldphys;
  458. long u_stack;
  459.  
  460. open_vwork();
  461. help=0;
  462.  
  463. /*** save VDI settings for restoration ***/
  464. vqm_attributes(handle,polym_sets);
  465. vql_attributes(handle,line_sets);
  466. line_sets[4]=intout[3];  line_sets[5]=intout[4];
  467. vqf_attributes(handle,fill_sets);
  468. vqt_attributes(handle,text_sets);
  469.  
  470. hide_mouse();
  471.  
  472. install_int();  init_snds();
  473.  
  474. /**** get original color palette ****/
  475. reg=0;
  476. plex=0;
  477. do {
  478.     vq_color(handle,reg,1,org_color[reg]);
  479.     reg++;
  480.  } while (reg != 16);
  481.  
  482. /* save menu bar*/
  483. /* if I do this much past 870 the string constants get screwed */
  484. oldphys = ( char *)Physbase();
  485.     a=0;
  486.     b=0;
  487.     u_stack = Super(0L);
  488.      do {
  489.         m_bar[b]= peekw(oldphys+a); 
  490.         a ++;
  491.         b ++;
  492.         } while(b<800);
  493.     Super(u_stack);
  494. clip_set();
  495.         
  496. form_dial(0,0,0,0,0,0,0,639,399);
  497.  
  498. /*Store GIST sounds for restore */
  499. only_1st_time++;
  500. if(only_1st_time==1) {
  501.    for(snd_num=0;snd_num<20;snd_num++) {
  502.          for(snd_ele=0;snd_ele<56;snd_ele++) {
  503.            switch(snd_num) {
  504. case 0: snd_patches[0][snd_ele]=aa[snd_ele]; break;
  505. case 1: snd_patches[1][snd_ele]=ab[snd_ele]; break;
  506. case 2: snd_patches[2][snd_ele]=ac[snd_ele]; break;
  507. case 3: snd_patches[3][snd_ele]=ad[snd_ele]; break;
  508. case 4: snd_patches[4][snd_ele]=ae[snd_ele]; break;
  509. case 5: snd_patches[5][snd_ele]=af[snd_ele]; break;
  510. case 6: snd_patches[6][snd_ele]=ag[snd_ele]; break;
  511. case 7: snd_patches[7][snd_ele]=ah[snd_ele]; break;
  512. case 8: snd_patches[8][snd_ele]=ai[snd_ele]; break;
  513. case 9: snd_patches[9][snd_ele]=aj[snd_ele]; break;
  514. case 10: snd_patches[10][snd_ele]=ak[snd_ele]; break;
  515. case 11: snd_patches[11][snd_ele]=al[snd_ele]; break;
  516. case 12: snd_patches[12][snd_ele]=am[snd_ele]; break;
  517. case 13: snd_patches[13][snd_ele]=an[snd_ele]; break;
  518. case 14: snd_patches[14][snd_ele]=ao[snd_ele]; break;
  519. case 15: snd_patches[15][snd_ele]=ap[snd_ele]; break;
  520. case 16: snd_patches[16][snd_ele]=aq[snd_ele]; break;
  521. case 17: snd_patches[17][snd_ele]=ar[snd_ele]; break;
  522. case 18: snd_patches[18][snd_ele]=as[snd_ele]; break;
  523. case 19: snd_patches[19][snd_ele]=landing[snd_ele]; break;
  524.  
  525.             } /* end switch */
  526.           } /* end for snd_ele */
  527.     } /* end for snd_num */
  528.   } /* endif only_1st_time */
  529.  
  530. help_1display();
  531.  
  532.  
  533. flag1=5;
  534. g_on=1;
  535.  
  536. for(;;) {
  537.     vq_mouse(handle,&butdown,&mx,&my);
  538.     if(mouse_CR && butdown==1) {
  539.         while(butdown==1) vq_mouse(handle,&butdown,&mx,&my);
  540.             while(Bcostat(BC_AUX)==0);
  541.             Bconout(BC_AUX,13);
  542.          if(mouse_CR==2) Bconout(BC_AUX,10);
  543.         }
  544.     if(butdown==2 && x_r_but==1) {
  545.         for(a=1;a<=r_but_tran[0];a++) {
  546.             while(Bcostat(BC_AUX)==0);
  547.             Bconout(BC_AUX,r_but_tran[a]);
  548.          }
  549.     while(Bcostat(BC_AUX)==0);
  550.     if(r_but_tran[81]) Bconout(BC_AUX,13);
  551.     while(butdown) { vq_mouse(handle,&butdown,&mx,&my); }
  552.      }
  553.     
  554.  
  555.     if (Bconstat(BC_CON)) {
  556.         key = Bconin(BC_CON);
  557.         if ((int)key == 0) {
  558.             key >>= 16;
  559.             if (key == KC_UNDO) {
  560.                 Cconws("\33f");
  561.                 if(!Getrez()) rez_change_med();
  562.                 flash_fix();
  563.                 /* left shift do a elimatnate status line */
  564.                 if(Kbshift(-1)==2)  Setscreen(-1L,-1L,original_rez);
  565.                 break;
  566.              }
  567.             if(key == KC_F5) {
  568.           if(r_lock==1)  r_lock=0;  else  { r_lock=1; Bconout(CON,7); }
  569.              }
  570.             if (key == KC_HELP)
  571.                 help_display();
  572.  
  573.             if (key == KC_INS)
  574.               /*  configure baud */
  575.                 set_baud();
  576.  
  577.             if (key == KC_CLR) {
  578.          /* restore attributes  and pallet */
  579.                 if(!Getrez)   rez_change_med(); 
  580.                 org_pallet();
  581.                 reset_attributes();
  582.                 Cconws("\33q\33c0\33b3\33E");
  583.                 }
  584.         /* CURSOR MOVEMENT from KEYBOARD */
  585.         if(key==KC_CUP) { Bconout(BC_AUX,27); Bconout(BC_AUX,'A'); 
  586.             if(plex) Cconws("\33A");
  587.         }
  588.         if(key==KC_CDOWN) { Bconout(BC_AUX,27); Bconout(BC_AUX,'B'); 
  589.             if(plex) Cconws("\33B");
  590.         }
  591.         if(key==KC_CLEFT)  { Bconout(BC_AUX,27); Bconout(BC_AUX,'D');
  592.             if(plex) Cconws("\33D");
  593.         }
  594.         if(key==KC_CRIGHT) { Bconout(BC_AUX,27); Bconout(BC_AUX,'C');
  595.             if(plex) Cconws("\33C");
  596.         }
  597.  
  598.             if (key == KC_F10)
  599.                /* F10 graphics off */
  600.                 g_on=0;
  601.  
  602.             if (key == KC_F6) {
  603.               /* half plex toggle */
  604.                 plex++;
  605.                 if(plex>1) {  plex=0;  Cconws("\n\rFULL PLEX"); }
  606.                 if(plex) Cconws("\n\rHALF PLEX");
  607.                 }
  608.  
  609.             if (key == KC_F4) {
  610.               /* MIDI on\off toggle */
  611.                 midi_on++;
  612.                 if(midi_on>1) {  midi_on=0;  Cconws("\n\rMIDI off\n\r"); }
  613.                 if(midi_on) Cconws("\n\rMIDI on\n\r");
  614.                 }
  615.  
  616.         if (key == KC_F8 || key==KC_F7) {
  617.              /* F8 display file */
  618.             help=0;
  619.             if (key==KC_F7) help=2;
  620.             file_find(); file_length = num_bytes;
  621.             bytes_left = file_length;
  622.  
  623.             if (file_length>0) {
  624.                 filehandle = Fopen(&filename[2],1);
  625.             if(filehandle>=0)  {
  626.                  display_file();
  627.                      Fclose(filehandle);
  628.                   }
  629.                 }
  630.                  }
  631.  
  632.             if (key == KC_F9)
  633.               /* F9  graphics on */
  634.                   g_on=1;    
  635.  
  636.                 } else {
  637.                     while (Bcostat(BC_AUX) == 0)
  638.                         ;
  639.                     Bconout(BC_AUX, (int)key);
  640.                     if(plex) Bconout(BC_CON, (int)key);
  641.                 }
  642.             }
  643.             if (Bconstat(BC_AUX)) {
  644.                 key = Bconin(BC_AUX);
  645.  
  646.     if ((flag1==0 && (int)key != '#') || (flag1==0 && g_on==0)) {
  647.                  Bconout(BC_CON,'G');
  648.             if((int)key!='G') Bconout(BC_CON, (int)key);
  649.                     }
  650.   
  651.                 if (flag1 !=0 && (int)key != 'G' )
  652.                  Bconout(BC_CON, (int)key);
  653.  
  654.                 if(des_backsp && (int)key==8) {
  655.                     Bconout(BC_CON,32); Bconout(BC_CON,8);
  656.                 }
  657.  
  658.                 flag1++;
  659.                 if ( flag1 > 30000 )   flag1=5;
  660.                 if ( (int)key =='G' )  flag1=0;
  661.                 if ( (int)key =='#' && flag1 == 1 && g_on )
  662.                       do_graphics();
  663.             }
  664.         } 
  665.  
  666.  
  667. org_pallet();
  668. reset_attributes();
  669. remove_int();
  670. res=Getrez();
  671. if (!res && original_rez==1 ) rez_change_med();
  672. Cconws("\33E\33f\33q\33c0\33b3\33Y7o");
  673. form_dial(3,0,0,0,0,0,0,639,399);
  674. show_mouse();
  675. /* restore menu bar */
  676.     a=0;
  677.     b=0;
  678.     u_stack = Super(0L);
  679.     do {
  680.         pokew(oldphys+a,m_bar[b]);
  681.         a ++;
  682.         b ++;
  683.         } while(b<800);
  684.     Super(u_stack);
  685.     clip_set();
  686.     line[0]=0; line[1]=10; line[2]=639; line[3]=10;
  687.  
  688.  /* drop line lower for mono */
  689.   if (original_rez==2) { line[1]=19; line[3]=19; }
  690.    v_pline(handle, 2, line); 
  691. }
  692.  
  693. /********************************************************/
  694. do_graphics() {
  695.  
  696. int points[2], sides[4], rgb[3], rgb2[3];
  697. static int current_palette[16] [3], previous_palette[16] [3];
  698. int recieving, key, chain, rez, ct, i,lp_ct,did_loop;
  699. int p1, p2, p3, val, v1, v2, v3, tries, out_of_range;
  700. int v4,v5,v6,v7,pxy[8],settings[4],snd_num,snd_ele;
  701. unsigned char rx,ry, is_gang='X', chain_gang[132];
  702. unsigned long rd, clock_t, timer1, timer2;
  703.  
  704. do {
  705.  
  706. recieving=1;  ct=0,did_loop=0;
  707. timer1 = clock1();
  708. while (recieving) {
  709.         timer2 = clock1();
  710.             if (Bconstat(BC_AUX)) {
  711.             ct++;
  712.         if ( ct==1 )  key = Bconin(BC_AUX);
  713.         if ( ct==2 ) {
  714.                       chain = Bconin(BC_AUX);
  715.               recieving=0;
  716.               }
  717.              }
  718.  
  719.     /* time out in 5 seconds */
  720.     if ( ((timer2/CLK_TCK)-(timer1/CLK_TCK)) > 4 ) {
  721.             recieving=0; chain='X';
  722.         Bconout(BC_CON,7);
  723.            }
  724.  
  725.  }     
  726. if (key=='&') {  /*** LooP command settings ***/
  727. /* & From,To,Step,Delay,COMMAND(, or |=Xor @=get_text)num_prams,x,y,const */
  728.     lp_flg=0; 
  729.     lp1=value(0); lp2=value(0); lp3=value(0); lp4=value(0);
  730.     if(lp1>lp2){  lp_ct=lp3; lp3=0-lp_ct;  }
  731.     if(lp3==0) lp3=1;
  732.     key=get_aux_char(); lp_com=is_gang=key;
  733.     if(is_gang=='>') { 
  734.         get_text();
  735.         for(v1=0; v1<128; v1++) chain_gang[v1]=text[v1];
  736.      }
  737.     lp_type=get_aux_char(); lp_num_prams=value(0);
  738.     if (lp_num_prams<1) lp_num_prams=1;
  739.     if(lp_num_prams>2048) lp_num_prams=2048;
  740.     lp_flg=0; /* 1st pass set array flags */
  741.     lp5=lp1;
  742.     r_lp=1; /* set rnd detect make flgs in array */
  743.     for(lp_ct=0;lp_ct<lp_num_prams;lp_ct++) lp_effect[lp_ct]=value(0); 
  744.     lp_eff_ct=0; lp_1st=0; lp_flg=1; lp_2nd=0; lp_no_prams=1;
  745.             did_loop=1;
  746.             r_lp=0; /* set rnd for normal operation */
  747.             w_1st_pass=0; /* zero flag for get_text */
  748.             xoff();
  749.     for(lp_ct=0;lp_ct<lp_num_prams;lp_ct++) {
  750.     if (lp_effect[lp_ct]== -32767 || lp_effect[lp_ct]== -32766 || (lp_effect[lp_ct]> -30000 && lp_effect[lp_ct]<0)) lp_no_prams=0;
  751.      }
  752.  
  753.     }
  754.  
  755. do {   /** do Loop for the '&' command **/
  756.      bad_cmd=0;
  757.      if(is_gang=='>') {
  758.         v1=value(0);
  759.         if(v1<0 || v1>127) v1=0;
  760.         key=lp_com=chain_gang[v1];
  761.      }
  762. /******Graphics commands section ******/
  763. if(key=='<') {  /*  GET_KEY_TRAN  < x,y,z
  764.                     x=0 tran key only
  765.                     x=1 tran with CR
  766.                     y=0 hot key input
  767.                     y=1 CR required
  768.                     y=2 MOUSE ZONE
  769.                     z= output choice to screen? 1=yes 0=no 
  770.                         2=yes toss, 3=no toss <- if toss no transmitt
  771.                         anything.
  772.                     GET a keys remember till chain is broke
  773.                     then transmit to host.  */
  774.         mem_key_cr=value(0); val=value(0); v5=value(0);
  775.         mem_key_flg=1; mem_key_ct=0;
  776.             if(v5==2) mem_key_flg=0;
  777.             if(v5==3) { v5=0; mem_key_flg=0; }
  778.         do {
  779.          if(val!=2) {
  780.             v4=Bconin(BC_CON);
  781.             if(v4==127 || v4==8 && mem_key_ct>0) mem_key_ct--;
  782.             if(v4>31 && v4<127) {
  783.                 if(mem_key_ct<129) {
  784.                  mem_key_ct++;
  785.                  mem_key[mem_key_ct]=v4;
  786.                  if(v5) Bconout(BC_CON,mem_key[mem_key_ct]);
  787.                 }
  788.             } 
  789.             if(v5 && v4==127 || v4==8) {
  790.                     Bconout(BC_CON,27);  Bconout(BC_CON,'D');
  791.                     Bconout(BC_CON,' '); 
  792.                     Bconout(BC_CON,27);  Bconout(BC_CON,'D');
  793.             }
  794.         if(v4==13) val=0;
  795.         } /* endif val!=2) */
  796. /************************************/
  797.     if(val==2) { /* MOUSE ZONE for POINT and CLICK */
  798.                  /* part of the "<" command. */
  799.     zone_jmp:
  800.         vq_mouse(handle,&v1,&v2,&v3);
  801.             /* poll the mouse */
  802.                 vqm_attributes(handle,settings);
  803.                 vswr_mode(handle,3);
  804.                 i=0; points[0]=10000; points[1]=10000;
  805.                           
  806.             do { vq_mouse(handle,&v1,&v2,&v3);
  807.  
  808.                 if( points[0] != v2  ||  points[1] != v3) {
  809.                     if(i==1) v_pmarker(handle,1,points);
  810.                  points[0]=v2; points[1]=v3; i=1;
  811.                  v_pmarker(handle,1,points);
  812.                  }
  813.                 
  814.                  } while(!v1);
  815.  
  816.             /* don't exit till button released */
  817.             do  vq_mouse(handle,&p1,&p2,&p3); while(p1);
  818.                  v_pmarker(handle,1,points);
  819.                  vswr_mode(handle,settings[3]);
  820.         v7=1;
  821.         if(zone_loopback) v7=2;
  822.         for(i=0;i<=47;i++) {
  823.         if(v2>=zone[i][0] && v2<=zone[i][2] && v3>=zone[i][1] && v3<=zone[i][3] )
  824.             { v7=0;    break; }
  825.          }
  826.         if(v7==1) i=47; /* default to last zone */
  827.         if(v7==2) { Bconout(BC_CON,7); goto zone_jmp; }
  828.         mem_key_ct=zone_cmds[i][0];
  829.         for(v6=1;v6<mem_key_ct+1;v6++) mem_key[v6]=zone_cmds[i][v6];         
  830.         val=0;
  831.        } /* endif (val==2) */
  832.  
  833.         } while(val>0);
  834. }
  835.  
  836. if(key=='N') {  /* NOISE   N x,num_bytes */
  837.                 /* x=0 load midi buff */
  838.                 /* x=1 load and execute */
  839.                 /* x=2 execute buff NO num_bytes given */
  840.                 /* x=3 load buff for CHIP */
  841.                 /* x=4 load buff for chip and exe */
  842.                 /* x=5 exe buff with chip commands */
  843.  
  844.             val=value(0);
  845.             if(val==2 || val==5) v1=midi_len;
  846.     if(val!=2 && val!=5) {  
  847.             v1=value(0);
  848.             midi_len=v1;
  849.             for(p1=0;p1<v1;p1++) {
  850.                  ig_midi[p1]=get_aux_char();
  851.                 if(Bconstat(BC_CON)) { 
  852.                         v7=Bconin(BC_CON);
  853.                  if(v7==3 || v7==24) { midi_len=0; val=0; break; }
  854.                  }
  855.              }
  856.  
  857.             if(val==0 || val>2) { p3=midi_on; midi_on=0; }
  858.      }
  859.  
  860.     if(midi_on && val<3) {
  861.             xoff();
  862.             for(p2=1;p2<v1;p2+=2) {
  863.             while(!Bcostat(3));
  864.                 if(Bconstat(BC_CON)) { 
  865.                         v7=Bconin(BC_CON);
  866.                  if(v7==3 || v7==24)  break;
  867.                  if(v7=='+') p2++;
  868.                  }
  869.                  if(p2>10000) p2=10000;
  870.  
  871.             v2=ig_midi[p2-1];
  872.             /* MIDI out */
  873.             Bconout(3,v2);
  874.             timer1=clock1();
  875.             /* do timing */
  876.             while(clock1()-timer1<ig_midi[p2]);
  877.              }
  878.            xon();
  879.      } /*endif midi_on*/
  880.     if(val==0 || val>2) midi_on=p3;
  881.     if(val==4 || val==5 && v1>5) {
  882.      for(p1=0;p1<v1;p1+=6) {
  883.                 if(Bconstat(BC_CON)) { 
  884.                         v7=Bconin(BC_CON);
  885.                  if(v7==3 || v7==24) break;
  886.                  if(v7=='+') p1++;
  887.                  }
  888.                  if(p1>10000) p1=10000;
  889.  
  890.         play_note(ig_midi[p1],ig_midi[p1+1],ig_midi[p1+2],ig_midi[p1+3],ig_midi[p1+4],ig_midi[p1+5]);    
  891.       }
  892.      }
  893.  
  894.  }
  895.  
  896. if (key=='X') {  /*  extended commands section  */
  897.          /*  extended commands are identified by a 
  898.              X and a number value 0 thru 9999.  This
  899.              allows 10,000 new commands to be introduced. */
  900.           val= value(0);
  901. /*----------------------------------------------------------------------------*/
  902.         /* 0, left_x,left_y, range_x,range_y, num_dots    spray paint */
  903.         /*  the ranges can only be 0 thru 255 */
  904.             if(val==0) {
  905.                 p1= value(1); p2= value(2); v1= value(1);
  906.                 v2= value(2); v3= value(0);
  907.                 for(p3=0;p3<v3;p3++) {
  908.                 rd=Random();
  909.                 rx=(char)rd;
  910.                 rd=Random();
  911.                 ry=(char)rd;
  912.                 tries=0;            
  913.                 do {
  914.                     tries++;
  915.                     out_of_range=0;
  916.                     if(rx>v1) { out_of_range=1;
  917.                         rd=Random(); rx=(char)rd; }
  918.                     if(ry>v2) { out_of_range=1;
  919.                         rd=Random(); ry=(char)rd; }
  920.                   if(tries>8) { out_of_range=0; rx=0; ry=0; }
  921.                    } while(out_of_range);
  922.             points[0]=p1+rx;    points[1]=p2+ry;
  923.             v_pmarker(handle,1,points);
  924.                 }
  925.             }
  926.             /***** end of spray paint *****/    
  927.  
  928.     /***************************Setcolor register**************************/
  929.         /*  X 1,register,value       
  930.             register 0-15  value 0-1911 */
  931.         if(val==1) {   /*  Setcolor register with Xbios */
  932.  
  933.             p1= value(0);  p2= value(0);
  934.             if(p1>15) p1=15;
  935.         /*    if(p2>1911) p2=1911;   kill may allow 4096 colors */ 
  936.             Setcolor(p1,p2);
  937.  
  938.         }
  939.     /******** Set RANDOM from to range *******/
  940.         /* X 2,from,to  */
  941.     if(val==2) {
  942.                 rnd_f=value(0);  rnd_t=value(0);
  943.                 if(rnd_f<0) rnd_f=0;
  944.                 if(rnd_t<rnd_f) rnd_t=rnd_f+1;
  945.                 }
  946.  /**** Right button tran command string ***
  947.    X 3,operation|,CR?,number of chars in tran string,tran string. */
  948.     if(val==3) {
  949.             v1=value(0);
  950.             if(v1>2) v1=0;
  951.             if(v1==0) x_r_but=0; /* X 3,OFF? */
  952.             if(v1==1) { /* X 3,ON,CR? */
  953.                 x_r_but=1; r_but_tran[81]=value(0);
  954.              }
  955.             if(v1==2) { /*X 3,2,ON,CR?,string len,string */
  956.              v4=value(0);
  957.              if(v4==0) x_r_but=0; else x_r_but=1;
  958.              r_but_tran[81]=value(0);
  959.              r_but_tran[0]=value(0);
  960.              if(r_but_tran[0]>80) r_but_tran[0]=80;
  961.              if(r_but_tran[0]<1) r_but_tran[0]=1;
  962.              if(lp_flg==1) xon();
  963.              for(v2=1;v2<=r_but_tran[0];v2++)
  964.                  r_but_tran[v2]=get_aux_char();
  965.              v3=get_aux_char(); /* dead get for seperator */
  966.              }        
  967.  
  968.         }
  969.  
  970. /************ LOAD ZONE DATA FOR POINT & CLICK *******/
  971.         if(val==4) {  /* zone_num,up_left_x,up_left_y,
  972.                          lower_right_x,lower_right_y,
  973.                          cmd_string_len,cmd_string: */
  974.             v1=value(0);  if(v1>47 && v1!=9999 && v1!=9998 && v1!=9997) v1=47; /* zone_num */
  975.  
  976.         /*  if X 4,9999: zero zones  */
  977.         if(v1==9999) for(p1=0;p1<48;p1++) {
  978.                         zone[p1][0]=-1;
  979.                         zone[p1][1]=-1;
  980.                         zone[p1][2]=-1;
  981.                         zone[p1][3]=-1;
  982.                         }
  983.         /* if X 4,9998:  SET ZONE loopback on invalid selection */
  984.         if(v1==9998) zone_loopback=1; /*ON*/
  985.         if(v1==9997) zone_loopback=0; /*OFF*/
  986.  
  987.           if(v1<9997) {
  988.             zone[v1][0]=value(1); /* up_left_x */
  989.             zone[v1][1]=value(2); /* up_left_y */
  990.             zone[v1][2]=value(1); /* lower_right_x */
  991.             zone[v1][3]=value(2); /* lower_right_y */
  992.  
  993.             v2=value(0);  if(v2>80) v2=80;  /* cmd_string_len */
  994.             if(v2<1) v2=1;
  995.             zone_cmds[v1][0]=v2;
  996.             if(lp_flg==1) xon();
  997.             for(v3=1;v3<=zone_cmds[v1][0];v3++)
  998.                 zone_cmds[v1][v3]=get_aux_char();
  999.             v4=get_aux_char(); /* dead get for seperator */
  1000.  
  1001.           } /* endif v1<9997 */
  1002.          }
  1003.  
  1004.  
  1005. /************   XON XOFF shutdown ***************/
  1006.         if(val==5) { /* 0=off 
  1007.                         1=on */
  1008.                      /* 2=set xon  xtimes */
  1009.                      /* 3=set xoff xtimes*/
  1010.                      /* 4 = set default */
  1011.  
  1012.             x_on=value(0);
  1013.             if(lp_flg) x_on=1;
  1014.  
  1015.             if(x_on==2) { 
  1016.                 x_on_char=value(0);
  1017.                 x_times=value(0);
  1018.              }
  1019.             if(x_on==3) {
  1020.                 x_off_char=value(0);
  1021.                 x_times_x=value(0);
  1022.              }
  1023.             if(x_on>3) {
  1024.                  x_on_char=17; x_off_char=19;
  1025.                  x_times=1; x_times_x=1;
  1026.              }
  1027.             }
  1028.  
  1029.  
  1030. /************  LEFT MOUSE BUTTON AS CR\LF  ON OFF  ****/
  1031.         if(val==6) {  /* 0= OFF  1=ON CR  2=ON CR\LF */
  1032.             mouse_CR=value(0);
  1033.         }
  1034.  
  1035. /********* X 7 left BLANK for now *******/
  1036.  
  1037.  /******* X 8,from,to,times,delay:   Color Rotation *******/
  1038.         if(val==8) {
  1039.           v1=value(0);  v2=value(0);  v3=value(0); v4=value(0);
  1040.  
  1041.          if(v1==1 && v2==1 && v3==1 && v4==1) { /* store palette */
  1042.           for(v5=0; v5<=15; v5++) 
  1043.             vq_color(handle, v5, 0, previous_palette[v5]);
  1044.            }
  1045.  
  1046.           if(v1>15 || v1<0) v1=15;
  1047.           if(v2>15 || v2<0) v2=15;
  1048.  
  1049.           if(v3!=0 && v1!=v2) { /* don't rotate if times= 0 or from= to */
  1050.             if(lp_flg!=1) xoff();
  1051.             for(v6=0; v6<=v3; v6++) {
  1052.              if(v1<v2) {     /* rotate right */
  1053.                 vq_color(handle,v2,0, rgb);
  1054.                 for(v5=v2; v5>=v1; v5--) {
  1055.                     vq_color(handle,v5-1,0,rgb2);
  1056.                     Vsync();
  1057.                      vs_color(handle,v5,rgb2);
  1058.                 }
  1059.                     Vsync();
  1060.                     vs_color(handle,v1,rgb);
  1061.              }
  1062.  
  1063.       if(v1>v2) {     /* rotate left */
  1064.         vq_color(handle,v2,0,rgb);
  1065.         for(v5=v2; v5<=v1; v5++) { 
  1066.         vq_color(handle,v5+1,0,rgb2);
  1067.         Vsync();
  1068.         vs_color(handle,v5,rgb2);
  1069.         }
  1070.         Vsync();
  1071.         vs_color(handle,v1,rgb);
  1072.       }
  1073.       delay (v4);
  1074.       if(Bconstat(BC_CON)) {Bconin(BC_CON); v6=v3+1; }
  1075.  
  1076.             } /* next v6 */
  1077.         if(lp_flg!=1) xon();
  1078.           }
  1079.  
  1080.           if(v3==0) {     /* restore previous palette */
  1081.             for(v5=0; v5<=15; v5++) vs_color(handle,v5,previous_palette[v5]);
  1082.           }
  1083.  
  1084.     } /* end of X 8 routine */
  1085.  
  1086.     
  1087.  
  1088.   }
  1089.  
  1090.  
  1091. if(key=='?') {  /* The INQUIRE command. */
  1092.     val=value(0);
  1093.     while(Bcostat(BC_AUX)==0);    
  1094.  
  1095.     if(val==0) {    /* VERSION */
  1096.         Bconout(BC_AUX,'2'); Bconout(BC_AUX,'.');
  1097.         Bconout(BC_AUX,'1'); Bconout(BC_AUX,'7');
  1098.      } 
  1099.     if(val==1) { /* ? 1,mouse?
  1100.                     CURSOR POSITION send X(column) & Y(row) & Mbutton
  1101.                    back in ASCII character form,-32 offset to
  1102.                    0-79, 0-24, 0-3 */
  1103.  
  1104.             v4=value(0);
  1105.             /* CURSOR MOVEMENT FROM MOUSE */
  1106.     vq_mouse(handle,&butdown,&mx,&my);
  1107.     if(v4){
  1108.             do {
  1109.                 vq_mouse(handle,&butdown,&mx,&my);
  1110.                 if(mx<v2) Cconws("\33D");
  1111.                 if(mx>v2) Cconws("\33C");
  1112.                 if(my<v3) Cconws("\33A");
  1113.                 if(my>v3) Cconws("\33B");        
  1114.                 p3=butdown; v2=mx; v3=my;
  1115.                 } while(!p3);
  1116.             do { vq_mouse(handle,&v1,&v2,&v3);  } while (v1);
  1117.      }
  1118.  
  1119.         vq_curaddress(handle,&p2,&p1); p3=butdown;
  1120.         p2+=31; p1+=31; p3+=32;
  1121.         Bconout(BC_AUX,p1); Bconout(BC_AUX,p2); Bconout(BC_AUX,p3);
  1122.      }
  1123.  
  1124.     if(val==2) { /* ? 2,x  Send back mouse coordinates, button */
  1125.         v4=value(0);
  1126.         vq_mouse(handle,&v1,&v2,&v3);
  1127.         if(v4) {
  1128.             /* poll the mouse */
  1129.                 vqm_attributes(handle,settings);
  1130.                 vswr_mode(handle,3);
  1131.                 i=0; points[0]=10000; points[1]=10000;
  1132.                           
  1133.             do { vq_mouse(handle,&v1,&v2,&v3);
  1134.  
  1135.                 if( points[0] != v2  ||  points[1] != v3) {
  1136.                     if(i==1) v_pmarker(handle,1,points);
  1137.                  points[0]=v2; points[1]=v3; i=1;
  1138.                  v_pmarker(handle,1,points);
  1139.                  }
  1140.                 
  1141.                  } while(!v1);
  1142.  
  1143.             /* don't exit till button released */
  1144.             do  vq_mouse(handle,&p1,&v2,&v3); while(p1);
  1145.                  v_pmarker(handle,1,points);
  1146.                  vswr_mode(handle,settings[3]);
  1147.  
  1148.          }
  1149.         /* make mouse values transmit in ascii */
  1150.         v1+=48; v7=0;
  1151.         do {
  1152.             if(v2>9999) v2=9999;
  1153.             if(v7==1) v2=v3;
  1154.             if(v2>999) { v6=(v2/1000); Bconout(BC_AUX,v6+48); v2-=(v6*1000);
  1155.                 if(v2<100) Bconout(BC_AUX,'0'); }
  1156.             if(v2>99)  { v6=(v2/100); v6; Bconout(BC_AUX,v6+48); v2-=(v6*100);
  1157.                 if(v2<10) Bconout(BC_AUX,'0'); }
  1158.             if(v2>9)   { v6=(v2/10); Bconout(BC_AUX,v6+48); v2-=(v6*10); }
  1159.             if(v2>0)   { v6=v2; Bconout(BC_AUX,v6+48); } else  Bconout(BC_AUX,'0');
  1160.             v7++; Bconout(BC_AUX,',');
  1161.             } while(v7<2);
  1162.             Bconout(BC_AUX,v1); Bconout(BC_AUX,':');
  1163.      }
  1164.     
  1165.     if(val==3) { /* send the host the current rez */
  1166.         i=Getrez();
  1167.         i+=48;
  1168.         Bconout(BC_AUX,i); Bconout(BC_AUX,':');
  1169.      }
  1170.     }
  1171.  
  1172.  
  1173. if (key=='G') { /* Grab a piece of the screen. */
  1174. /* G to_screen_or_mem,mode,xs1,ys1,| xs2,ys2, |  xd1,yd1 */
  1175.     vq_extnd(handle,1,work_out);
  1176.     val=value(0); v7=value(0);
  1177.     v1=value(1); v2=value(2); 
  1178.  
  1179.     if(val==2) { v3=(vd3-vd1)+v1; v4=(vd4-vd2)+v2; }
  1180.  
  1181.     if(val==1 || val==0 || val==3) { v3=value(1); v4=value(2); }
  1182.     
  1183.     if(val==0 || val==3) { /* if blit to screen get dest area */ 
  1184.         v5=value(1); v6=value(2); 
  1185.      }
  1186.     
  1187.  
  1188.     p1=Getrez();
  1189.     if(p1>2) p1=0; /* Limit to ST modes */
  1190.     if(p1==0) {
  1191.      if(v1>319) v1=319;
  1192.      if(v3>319) v3=319;
  1193.      if(v5>319) v5=319;
  1194.      }
  1195.     if(p1==0 || p1==1) {
  1196.      if(v2>199) v2=199;
  1197.      if(v4>199) v4=199;
  1198.      if(v6>199) v6=199;
  1199.      }
  1200.     if(p1==2) {
  1201.      if(v2>399) v2=399;
  1202.      if(v4>399) v4=399;
  1203.      if(v6>399) v6=399;
  1204.      }
  1205.     if(p1==1 || p1==2) {
  1206.      if(v1>639) v1=639;
  1207.      if(v3>639) v3=639;
  1208.      if(v5>639) v5=639;
  1209.      }
  1210.  
  1211.     pxy[0]=v1; pxy[4]=v1;
  1212.     pxy[1]=v2; pxy[5]=v2;
  1213.     pxy[2]=v3; pxy[6]=v3;
  1214.     pxy[3]=v4; pxy[7]=v4; 
  1215.     if(val==1) { vd1=v1; vd2=v2; vd3=v3; vd4=v4; }
  1216.     if(val==2) { pxy[0]=vd1; pxy[1]=vd2; pxy[2]=vd3; pxy[3]=vd4;
  1217.                  pxy[6]=(vd3-vd1)+v1; pxy[7]=(vd4-vd2)+v2; 
  1218.      }
  1219.  
  1220.  
  1221.  
  1222.     /* from 0=screen to screen, 1=screen to mem, 2=mem to screen */
  1223.     if(val>3) val=3;
  1224.     sourceMFDB.image=0L;
  1225.     destMFDB.image=bitblt_storage;
  1226.     destMFDB.width=vd3-vd1;
  1227.     destMFDB.height=vd4-vd2;
  1228.     destMFDB.wordw=((vd3-vd1)/16)+1;
  1229.     if(destMFDB.wordw>40) destMFDB.wordw=40;
  1230.     destMFDB.flag=0;
  1231.     destMFDB.planes=work_out[4];
  1232.  
  1233.     if(val==0 || val==3) { /* set dest area for a blit to screen */
  1234.         pxy[4]=v5; pxy[5]=v6; pxy[6]=(v3-v1)+v5; pxy[7]=(v4-v2)+v6;
  1235.       }
  1236.  
  1237.     if(v7>15) v7=3;  /* set to replace mode if err */
  1238.    for(i=0;i<8;i++) if(pxy[i]<0) pxy[i]=0;
  1239.     if(val==0) { destMFDB=sourceMFDB;
  1240.             vro_cpyfm(handle,v7,pxy,&sourceMFDB,&destMFDB);
  1241.           }
  1242.         if(val==1)     vro_cpyfm(handle,v7,pxy,&sourceMFDB,&destMFDB);
  1243.         if(val==2 || val==3)     vro_cpyfm(handle,v7,pxy,&destMFDB,&sourceMFDB);
  1244.     }
  1245.  
  1246.  
  1247. if (key=='I') {  /* I x    INITIALIZE  */
  1248.          /* inits to what ever the attributes of the calling 
  1249.             program or desktop were set to. */
  1250.          /* x = 0 init pallet and attributes */
  1251.          /* x = 1 init pallet  ONLY */
  1252.          /* x = 2 init attributes  ONLY  */
  1253.          /* x = 3 inti IG default pallete */ 
  1254.           val= value(0);
  1255.           if(val>3) val=0;
  1256.           if(val==0) { org_pallet(); reset_attributes(); }
  1257.           if(val==1)  org_pallet();
  1258.           if(val==2)  reset_attributes();
  1259.           if(val==3)  for(val=0; val<16; val++) vs_color(handle,val,sys_color[val] );
  1260.         } 
  1261.  
  1262. if (key=='A') {   /* A t p b   fill ATTRIBUTES  */
  1263.                   /*  t=type (0-3)  0=hollow 1=solid 2=pattern 3=hatch */
  1264.           /*  p=pattern (1-24) works only with pattern & hatch types */
  1265.           /*  b=border 0=no border any other value yields a border */
  1266.  
  1267.            val= value(0); p1= value(0); p2= value(0);
  1268.            if (val>3) val=0;
  1269.            vsf_interior(handle,val);
  1270.                    vsf_style(handle,p1);
  1271.            vsf_perimeter(handle,p2);
  1272.         }
  1273.  
  1274. if (key=='B') {  /*  B tlx tly brx bry r    BAR (rectangle) filled */
  1275.          /* tl=topleft corner x y cords. */
  1276.          /* br=bottom right x y cords. */
  1277.          /* r=rounded corners? (1=yes 0=no) */
  1278.  
  1279.            sides[0]= value(1); sides[1]= value(2);
  1280.            sides[2]= value(1); sides[3]= value(2);
  1281.            val= value(0);
  1282.            if ( ! val ) v_bar(handle,sides);
  1283.            if ( val )   v_rfbox(handle,sides);
  1284.         }
  1285.  
  1286. if (key=='C') {  /*  C x pen    -set polymarker, line, fill */
  1287.          /*  and "WRITTEN" text color */
  1288.          /* where x=(0-4) 0=marker 1=line 2=fill 3=text */
  1289.          /* pen = (0 - 15) VDI pen not color register */
  1290.  
  1291.            p1= value(0);
  1292.                    val= value(0); 
  1293.            if (val>15) val=0;
  1294.            if (p1>3) p1=0;
  1295.         if(p1==0)   vsm_color(handle,val); 
  1296.         if(p1==1)   vsl_color(handle,val);
  1297.         if(p1==2)   vsf_color(handle,val);
  1298.         if(p1==3)   vst_color(handle,val); 
  1299.         }
  1300.          
  1301. if (key=='D')  {   /* D x y     DRAWTO  */
  1302.            /* use P x y to set starting point and be sure */
  1303.            /* type is T 1 1 1 if you want a pixel point */
  1304.  
  1305.            lines[0]=lines[2];  lines[1]=lines[3];
  1306.            lines[2]= value(1); lines[3]= value(2);
  1307.            v_pline(handle,2,lines);
  1308.            lines[0]=lines[2];  lines[1]=lines[3];
  1309.         }
  1310.  
  1311. if (key=='E')  {  /* E font size rotation EFFECTS for "WRITTEN" text */
  1312.           /* font(1,2,4,8,16)  size(8,9,10,16,18,20 (in points 1/72") */
  1313.           /* rotation (0-4) = *90 degrees */
  1314.  
  1315.              p1= value(0); p2= value(0); p3= value(0);
  1316.              vst_effects(handle,p1);
  1317.              if (p3>4) p3=0;
  1318.              p3 *=900;
  1319.              vst_rotation(handle,p3);
  1320.              if (p2<8) p2=8;
  1321.              if (p2>20) p2=20;
  1322.              vst_point(handle,p2,&p1,&p3,&v1,&v2);
  1323.         }
  1324.  
  1325. if (key=='F')  {  /* F x y   FLOOD FILL color replace mode */
  1326.            p1=value(1); p2=value(2);
  1327.          if(lp_flg!=1)  xoff();
  1328.            v_contourfill(handle,p1,p2,-1);
  1329.            if(lp_flg!=1) xon();
  1330.         }
  1331.  
  1332. if (key=='H')  {  /* H x    HOLLOW ( frames ) */
  1333.           /*   x=1 on    x=0 off */
  1334.  
  1335.              val= value(0);
  1336.              if ( val>1 ) val=1;
  1337.              if ( val==1 ) {
  1338.             vsf_interior(handle,0);
  1339.             vswr_mode(handle,2);
  1340.             vsf_perimeter(handle,1);
  1341.             }
  1342.               if ( val == 0 ) {
  1343.             vsf_interior(handle,1);
  1344.             vswr_mode(handle,1);
  1345.             vsf_perimeter(handle,0);
  1346.             }
  1347.         }
  1348.  
  1349. if (key=='J')  {  /* J x y xradius yradius begin_angle end_angle */
  1350.           /* ELLIPTICAL ARC */
  1351.            p1= value(1); p2= value(2); p3= value(1);
  1352.            v1= value(2); v2= value(0); v3= value(0);
  1353.            v2 *= 10;   v3 *= 10;            
  1354.            v_ellarc(handle,p1,p2,p3,v1,v2,v3);
  1355.         }
  1356. if (key=='K')  {  /* K x y radius begin_angle end_angle    ARC   */
  1357.           p1= value(1); p2= value(2); p3= value(1);
  1358.           v1= value(0); v2= value(0);
  1359.           v1 *= 10;  v2 *= 10;
  1360.           v_arc(handle,p1,p2,p3,v1,v2);
  1361.         }
  1362.  
  1363. if (key=='Z')  { /* Z x_up_left y_up_left x_low_right y_low_right */
  1364.          /* FILLED RECTANGLE */
  1365.          sides[0]= value(1); sides[1]= value(2);
  1366.          sides[2]= value(1); sides[3]= value(2);
  1367.          vr_recfl(handle,sides);
  1368.         }
  1369.  
  1370. if (key=='U')  {  /* U left_edge top_edge right_edge bottom_edge fill_flag  */
  1371.           /* ROUNDED RECTANGLE */
  1372.           sides[0]= value(1); sides[1]= value(2);
  1373.           sides[2]= value(1); sides[3]= value(2);
  1374.           val= value(0);
  1375.           if (val==0) v_rbox(handle,sides);
  1376.           if (val>0 ) v_rfbox(handle,sides);
  1377.         }
  1378.             
  1379. if (key=='L')  {   /* L x y xEND yEND draw a line */
  1380.            lines[0]= value(1); lines[1]= value(2);
  1381.            lines[2]= value(1); lines[3]= value(2);
  1382.            v_pline(handle, 2, lines);    
  1383.         }
  1384.             
  1385. if (key=='M')  {   /* M x   graphics drawing MODE  */
  1386.            /* 1=replace, 2=Transparent, 3=XOR, 4=reverse transparent */
  1387.            val= value(0);
  1388.            if (val<1 || val>4) val=1;
  1389.            vswr_mode(handle,val);
  1390.         } 
  1391. if (key=='g')  {  /* g x   Set graphics scaling coordinates */
  1392.             val= value(0);
  1393.             if (val<0 || val>2) val=0;
  1394.                 g_s=val; g_res=Getrez();
  1395.         } 
  1396.  
  1397. if (key=='O')  {  /* O x y radius    CIRCLE  */
  1398.  
  1399.            p1= value(1); p2= value(2); p3= value(1);
  1400.            v_circle(handle,p1,p2,p3);
  1401.         }
  1402.  
  1403. if (key=='P')  {    /*   P x y  polymarker plot */
  1404.             points[0]= value(1); points[1]= value(2);
  1405.             v_pmarker(handle,1,points);
  1406.              lines[2]=points[0]; lines[3]=points[1];      
  1407.         }
  1408.  
  1409. if (key=='Q')  {  /* Q x y xradius yradius  OVAL (ellipse) */
  1410.  
  1411.              p1= value(1); p2= value(2); p3= value(1); val= value(2);
  1412.              v_ellipse(handle,p1,p2,p3,val);
  1413.         }
  1414.  
  1415. if (key=='R')  {   /* R x p   set resolution 0-1   sys pallete 0-2 */
  1416.            val= value(0); p1= value(0);
  1417.                    rez=Getrez();
  1418.                    if ( val< 0 || val>1 ) val=rez; 
  1419.             if (rez != 2 && rez!=val) {
  1420.                 if(val==0) rez_change_low();
  1421.                 if(val==1)  rez_change_med();
  1422.             }  /* Setscreen(-1L,-1L,val); */
  1423.            clip_set();
  1424.            if( p1==2 ) for(val=0; val<16; val++) vs_color(handle,val,sys_color[val]);
  1425.            if( p1==1 )  for(p1=0; p1<16; p1++) vs_color(handle,p1,org_color[p1]);
  1426.                    }
  1427.  
  1428. if (key=='S')  {   /* S pen red green blue   pen(0-15)  rgb(0-7) */
  1429.            /* SET PEN COLOR */
  1430.           val= value(0); rgb[0]= value(0);
  1431.            rgb[1]= value(0); rgb[2]= value(0);  
  1432.            if (val>15) val=0; 
  1433.                for(p1=0; p1<3; p1++) {
  1434.             p2=rgb[p1];
  1435.             switch(p2) {
  1436.                 case 1: rgb[p1]=142;
  1437.                     break;
  1438.                 case 2: rgb[p1]=285;
  1439.                     break;
  1440.                 case 3: rgb[p1]=428;
  1441.                     break;
  1442.                 case 4: rgb[p1]=571;
  1443.                     break;
  1444.                 case 5: rgb[p1]=714;
  1445.                     break;
  1446.                 case 6: rgb[p1]=857;
  1447.                     break;
  1448.                 case 7: rgb[p1]=1000;
  1449.                     break;
  1450.                 default: rgb[p1]=0;
  1451.                     break;
  1452.               }
  1453.               }
  1454.        vs_color(handle,val,rgb);     
  1455.         }
  1456.  
  1457. if (key=='T')  {   /* type of polymarker(1-6) and height(y*11) y=(1-8) */
  1458.            /* type of line(1-6) and thickness(1-40) */
  1459.            /* 1 for marker  2 for line */
  1460.                    /* G#T 1 3 8  marker     G#T 2 1 40 line */
  1461.            /*  T 2 1 50 (to 54) arrowhead endlines */
  1462.            /*  T 2 1 60 (to 64) rounded endlines */
  1463.            /*  T 2 1 0   square endlines */
  1464.            p1= value(0);                     
  1465.                    if ( p1<1 || p1>2 ) break;      
  1466.                      p2= value(0);          
  1467.            if ( p2<1 || p2>6 ) p2=1;       
  1468.  
  1469.                    if ( p1 == 1 ) {               
  1470.              p3= value(0);            
  1471.            if (p3<1 || p3>8 ) p3=1;      
  1472.             vsm_type(handle,p2);         
  1473.                     vsm_height(handle,p3*11);      
  1474.             }
  1475.                    
  1476.            if (p1==2) {              
  1477.             p3= value(0);
  1478.             
  1479.             if (p3<42 && p3>0) {          
  1480.               if (p2>1) p3=1; 
  1481.               vsl_type(handle,p2); 
  1482.               vsl_width(handle,p3);
  1483.             }
  1484.             if (p3==0)   vsl_ends(handle,0,0);
  1485.             if (p3==50)  vsl_ends(handle,1,1);
  1486.             if (p3==51)  vsl_ends(handle,1,0);
  1487.             if (p3==52)  vsl_ends(handle,0,1);
  1488.             if (p3==53)  vsl_ends(handle,1,2);
  1489.             if (p3==54)  vsl_ends(handle,2,1);
  1490.  
  1491.             if (p3==60)  vsl_ends(handle,2,2);
  1492.             if (p3==61)  vsl_ends(handle,2,0);
  1493.             if (p3==62)  vsl_ends(handle,0,2);
  1494.             if (p3==63)  vsl_ends(handle,2,1);
  1495.             if (p3==64)  vsl_ends(handle,1,2);
  1496.  
  1497.             }
  1498.           } 
  1499.  
  1500. if (key=='V')  {  /*  V x y radius beginangle endangle     PIESLICE  */
  1501.  
  1502.               p1= value(1); p2= value(2); p3= value(1);
  1503.               v1= value(0); v2= value(0);
  1504.               v1 *=10; v2 *=10;
  1505.               v_pieslice(handle,p1,p2,p3,v1,v2);
  1506.         }
  1507.  
  1508. if (key=='W')  {  /* W x y string    "WRITE" text to x y coord. */
  1509.              p1= value(1); p2= value(2); 
  1510.               get_text();
  1511.              v_gtext(handle,p1,p2,text);
  1512.         }
  1513.  
  1514. if (key=='Y')  {  /* Y x y xradius yradius beginangle endangle  OVAL-PIESLICE */
  1515.              p1= value(1); p2= value(2); p3= value(1);
  1516.              v1= value(2); v2= value(0); v3= value(0);
  1517.              v2 *=10; v3 *=10;
  1518.              v_ellpie(handle,p1,p2,p3,v1,v2,v3);
  1519.         }
  1520. if(key=='n')   {  /* n,  play_note */
  1521.                /* Musical Note Routine has 6 parameters p1-p6 */
  1522.                 /* 1 = effect number(0-19)    2 = voice number(0-2) */
  1523.                 /* 3 = volume(0-15)           4 = pitch(0-255)  */
  1524.                 /* 5 = pause in 200ths sec (0-9999) */
  1525.                 /* 6 = stop sotnd type (0-4)   */
  1526.             v1=value(0); v2=value(0); v3=value(0); v4=value(0);
  1527.             v5=value(0); v6=value(0);
  1528.             play_note(v1,v2,v3,v4,v5,v6);
  1529.  }
  1530.  
  1531. if (key=='t')  {  /* t x     TIME */
  1532.           /* pause BBS by sending a cntrl-s and time it for x seconds */
  1533.           /* then send a ctrl-q     30 second max */
  1534.            val= value(0);
  1535.            if(val>30) val=30;
  1536.  
  1537.            timer1 = clock1();
  1538.            if(lp_flg!=1) xoff();
  1539.  
  1540.            do {
  1541.             timer2 = clock1();
  1542.  
  1543.             if(Bconstat(BC_CON)(BC_CON)(BC_CON)(BC_CON)(BC_CON) /* br=bottom right x y cords. */
  1544.          /* r=rounded corners? (1=yes 0=no) */
  1545.  
  1546.            sides[0]= value(1); sides[1]= value(2);
  1547.            sides[2]= value(1); sides[3]= value(2);
  1548.            val= value(0);
  1549.            if ( ! val ) v_bar(handle,sides);
  1550.            if ( val )   v_rfbox(handle,sides);
  1551.         }
  1552.  
  1553. if (key=='C') {  /*  C x pen    -set polymarker, line, fill */
  1554.          /*  and "WRITTEN" text color */
  1555.          /* where x=(0-4) 0=marker 1=line 2=fill 3=text */
  1556.          /* pen = (0 - 15) VDI pen not color register */
  1557.  
  1558.            p1= value(0);
  1559.                    val= value(0); 
  1560.            if (val>15) val=0;
  1561.            if (p1>3) p1=0;
  1562.         if(p1==0)   vsm_color(handle,val); 
  1563.         if(p1==1)   vsl_color(handle,val);
  1564.         if(p1==2)   vsf_color(handle,val);
  1565.         if(p1==3)   vst_color(handle,val); 
  1566.         }
  1567.          
  1568. if (key=='D')  {   /* D x y     DRAWTO  */
  1569.            /* use P x y to set starting point and be sure */
  1570.            /* type is T 1 1 1 if you want a pixel point */
  1571.  
  1572.            lines[0]=lines[2];  lines[1]=lines[3];
  1573.            lines[2]= value(1); lines[3]= value(2);
  1574.            v_pline(handle,2,lines);
  1575.            lines[0]=lines[2];  lines[1]=lines[3];
  1576.         }
  1577.  
  1578. if (key=='E')  {  /* E font size rotation EFFECTS for "WRITTEN" text */
  1579.           /* font(1,2,4,8,16)  size(8,9,10,16,18,20 (in points 1/72") */
  1580.           /* rotation (0-4) = *90 degrees */
  1581.  
  1582.              p1= value(0); p2= value(0); p3= value(0);
  1583.              vst_effects(handle,p1);
  1584.              if (p3>4) p3=0;
  1585.              p3 *=900;
  1586.              vst_rotation(handle,p3);
  1587.              if (p2<8) p2=8;
  1588.              if (p2>20) p2=20;
  1589.              vst_point(handle,p2,&p1,&p3,&v1,&v2);
  1590.         }
  1591.  
  1592. if (key=='F')  {  /* F x y   FLOOD FILL color replace mode */
  1593.            p1=value(1); p2=value(2);
  1594.          if(lp_flg!=1)  xoff();
  1595.            v_contourfill(handle,p1,p2,-1);
  1596.            if(lp_flg!=1) xon();
  1597.         }
  1598.  
  1599. if (key=='H')  {  /* H x    HOLLOW ( frames ) */
  1600.           /*   x=1 on    x=0 off */
  1601.  
  1602.              val= value(0);
  1603.              if ( val>1 ) val=1;
  1604.              if ( val==1 ) {
  1605.             vsf_interior(handle,0);
  1606.             vswr_mode(handle,2);
  1607.             vsf_perimeter(handle,1);
  1608.             }
  1609.               if ( val == 0 ) {
  1610.             vsf_interior(handle,1);
  1611.             vswr_mode(handle,1);
  1612.             vsf_perimeter(handle,0);
  1613.             }
  1614.         }
  1615.  
  1616. if (key=='J')  {  /* J x y xradius yradius begin_angle end_angle */
  1617.           /* ELLIPTICAL ARC */
  1618.            p1= value(1); p2= value(2); p3= value(1);
  1619.            v1= value(2); v2= value(0); v3= value(0);
  1620.            v2 *= 10;   v3 *= 10;            
  1621.            v_ellarc(handle,p1,p2,p3,v1,v2,v3);
  1622.         }
  1623. if (key=='K')  {  /* K x y radius begin_angle end_angle    ARC   */
  1624.           p1= value(1); p2= value(2); p3= value(1);
  1625.           v1= value(0); v2= value(0);
  1626.           v1 *= 10;  v2 *= 10;
  1627.           v_arc(handle,p1,p2,p3,v1,v2);
  1628.         }
  1629.  
  1630. if (key=='Z')  { /* Z x_up_left y_up_left x_low_right y_low_right */
  1631.          /* FILLED RECTANGLE */
  1632.          sides[0]= value(1); sides[1]= value(2);
  1633.          sides[2]= value(1); sides[3]= value(2);
  1634.          vr_recfl(handle,sides);
  1635.         }
  1636.  
  1637. if (key=='U')  {  /* U left_edge top_edge right_edge bottom_edge fill_flag  */
  1638.           /* ROUNDED RECTANGLE */
  1639.           sides[0]= value(1); sides[1]= value(2);
  1640.           sides[2]= value(1); sides[3]= value(2);
  1641.           val= value(0);
  1642.           if (val==0) v_rbsnd_ele++) {
  1643.            switch(snd_num) {
  1644. case 0:  aa[snd_ele]=snd_patches[0][snd_ele]; break;
  1645. case 1:  ab[snd_ele]=snd_patches[1][snd_ele]; break;
  1646. case 2:  ac[snd_ele]=snd_patches[2][snd_ele]; break;
  1647. case 3:  ad[snd_ele]=snd_patches[3][snd_ele]; break;
  1648. case 4:  ae[snd_ele]=snd_patches[4][snd_ele]; break;
  1649. case 5:  af[snd_ele]=snd_patches[5][snd_ele]; break;
  1650. case 6:  ag[snd_ele]=snd_patches[6][snd_ele]; break;
  1651. case 7:  ah[snd_ele]=snd_patches[7][snd_ele]; break;
  1652. case 8:  ai[snd_ele]=snd_patches[8][snd_ele]; break;
  1653. case 9:  aj[snd_ele]=snd_patches[9][snd_ele]; break;
  1654. case 10:  ak[snd_ele]=snd_patches[10][snd_ele]; break;
  1655. case 11:  al[snd_ele]=snd_patches[11][snd_ele]; break;
  1656. case 12:  am[snd_ele]=snd_patches[12][snd_ele]; break;
  1657. case 13:  an[snd_ele]=snd_patches[13][snd_ele]; break;
  1658. case 14:  ao[snd_ele]=snd_patches[14][snd_ele]; break;
  1659. case 15:  ap[snd_ele]=snd_patches[15][snd_ele]; break;
  1660. case 16:  aq[snd_ele]=snd_patches[16][snd_ele]; break;
  1661. case 17:  ar[snd_ele]=snd_patches[17][snd_ele]; break;
  1662. case 18:  as[snd_ele]=snd_patches[18][snd_ele]; break;
  1663. case 19:  landing[snd_ele]=snd_patches[19][snd_ele]; break;
  1664.  
  1665.                         } /* end switch */
  1666.  
  1667.           } /* end for */
  1668.      } /* endif val==22 */
  1669. }
  1670.  
  1671.  
  1672. if(key=='i')  {   /* i x t  LINE INSERTS */
  1673.          /* x (0-1) 0= cursor up insert blanks if at top of screen */
  1674.          /* x (0-1) 1= insert line at cursor, bottom line is scrolled off */
  1675.          /* t = number of times to do this. */
  1676.         val= value(0); p1= value(0); 
  1677.         if(val>1) val=0;
  1678.         p2=0;
  1679.         do {
  1680.             Bconout(2,27);
  1681.             if(val==0) Bconout(2,'I');
  1682.             if(val==1) Bconout(2,'L');
  1683.             p2 ++;
  1684.             } while(p2<p1);
  1685.         }
  1686.  
  1687.  
  1688. if(key=='r')  {  /* r x  REMEMBER/RECALL cursor position */
  1689.          /* where x=0 remeber, x=1 recall */
  1690.         val= value(0);
  1691.         if(val>1) val=0;
  1692.         Bconout(2,27);
  1693.         if(val==0) Bconout(2,'j');
  1694.         if(val==1) Bconout(2,'k');
  1695.         }
  1696.  
  1697. if(key=='d')  {  /* d x  DELETE LINE scroll screen up a line at bottom. */
  1698.          /* x = number of lines to delete */
  1699.         val= value(0);
  1700.         p2=0;
  1701.         do {
  1702.             Bconout(2,27);
  1703.             Bconout(2,'M');
  1704.             p2 ++;
  1705.            } while(p2<val);
  1706.         }
  1707.  
  1708. if(key=='l')  {  /* l x  LINE CLEARS  */
  1709.          /*  x=0 clear whole line and <CR> cursor */
  1710.          /*  x=1 clear line from begining to cursor inclusive */
  1711.          /*  x=2 clear at cursor to end of line */
  1712.          val= value(0);
  1713.          if(val>2) val=0;
  1714.          Bconout(2,27);
  1715.          if(val==0) Bconout(2,'l');
  1716.          if(val==1) Bconout(2,'o');
  1717.          if(val==2) Bconout(2,'K');
  1718.         }
  1719.  
  1720. if(key=='s')  {  /*   s x    SCREEN CLEARS */
  1721.          /* where x=0  clear whole screen home cursor */
  1722.          /*       x=1 clear from home to cursor */
  1723.          /*       x=2 clear from cursor to bottom of screen */
  1724.          /*       x=3 clear whole screen with VDI */
  1725.          /*          x=4 clear with VDI & VT52 */
  1726.          /*          x=5 reverse off, background to 0, char color 3,
  1727.                       clear & home */
  1728.  
  1729.         val= value(0);
  1730.         if(val>5) val=0;
  1731.         if(val!=3) {
  1732.         Bconout(2,27);
  1733.         if(val==0 || val==4) Bconout(2,'E');
  1734.         if(val==1) Bconout(2,'d');
  1735.         if(val==2) Bconout(2,'J');
  1736.         if(val==5) Cconws("\33q\33c0\33b3\33E");
  1737.          }
  1738.         if(val==3 || val==4) v_clrwk(handle); 
  1739.         }
  1740.  
  1741. if(key=='p')  {  /* p column row    POSITION CURSOR x y */
  1742.          /* this is reverse to normal operation */
  1743.          /* reason is everything else is  X Y  */
  1744.          /* why not cursor positioning?  */
  1745.          p1= value(0); p2= value(0);
  1746.          p1+=32;  p2+=32;
  1747.          Bconout(2,27);  Bconout(2,'Y');
  1748.          Bconout(2,p2);  Bconout(2,p1);
  1749.         }
  1750.  
  1751. if(key=='c')  {  /* c f x  printed TEXT COLOR */
  1752.          /* f=0 set background  f=1 set text color */
  1753.          /* x  = color register */
  1754.         p1= value(0);  p2= value(0);
  1755.         if(p1>1) p1=0;
  1756.         Bconout(2,27);
  1757.         if(p1==0) { Bconout(2,'c'); Bconout(2,p2); }
  1758.         if(p1==1) { Bconout(2,'b'); Bconout(2,p2); }
  1759.         }
  1760.  
  1761. if(key=='v')  { /* v x   VIDEO (inverse on/off) */
  1762.         /* where x=0 off   x=1 on       */
  1763.         val= value(0);
  1764.         if(val>1) val=0;
  1765.         Bconout(2,27);
  1766.         if(val==0) Bconout(2,'q');
  1767.         if(val==1) Bconout(2,'p');
  1768.         }
  1769.  
  1770. if(key=='k')  { /* k x   CURSOR ( on/off ) and Destructive  Backspace */
  1771.         /* where x=0 off   x=1 on       */
  1772.         /* x=2 destructive backspace on, x=3 destruction off */
  1773.         val=value(0);
  1774.         if(val>3) val=0;
  1775.         if(val<2) Bconout(2,27);
  1776.         if(val==0) Bconout(2,'f');
  1777.         if(val==1) Bconout(2,'e');
  1778.         if(val==2) des_backsp=1;
  1779.         if(val==3) des_backsp=0;
  1780.         }
  1781.  
  1782. if(key=='w')  { /* w x   LINE WRAP ( on/off ) */
  1783.         /* where x=0 off   x=1 on       */
  1784.         val= value(0);
  1785.         if(val>1) val=0;
  1786.         Bconout(2,27);
  1787.         if(val==0) Bconout(2,'w');
  1788.         if(val==1) Bconout(2,'v');
  1789.         }
  1790.  
  1791.     } while(lp_flg==1 && bad_cmd !=0 ); /* end do  '&' command */
  1792.     if(did_loop==1) { did_loop=0;
  1793.             xon();
  1794.         }
  1795.         lp_type=' ';  is_gang='X'; /* zero @ option & LOOP; null gang */
  1796.  }  while ( chain == '>' );
  1797.  
  1798. if(mem_key_flg) { 
  1799.                     mem_key_flg=0;
  1800.          for(v1=1;v1<mem_key_ct+1;v1++) {
  1801.              while(Bcostat(BC_AUX) == 0);
  1802.            Bconout(BC_AUX,mem_key[v1]);
  1803.          }
  1804.            if(mem_key_cr) Bconout(BC_AUX,13);
  1805.  }
  1806.  
  1807. }
  1808. /*************/
  1809. get_text() {
  1810.  
  1811. int recieving, key, ct;
  1812. unsigned long clock_t, timer1, timer2;
  1813.  
  1814.  
  1815. recieving=1;  ct=0;
  1816. timer1 = clock1();
  1817. if(lp_flg==1 && lp_type !='@') recieving=0;
  1818.  
  1819. if(lp_flg==1 && lp_type=='@') {
  1820.         w_1st_pass++;
  1821.         if(w_1st_pass==1) {
  1822.            xon();
  1823.          }
  1824. }
  1825.  
  1826. if(lp_flg==0 && lp_type=='Z') { recieving=0; lp_type=' '; }
  1827. while (recieving) {
  1828.         timer2 = clock1();
  1829.             if (Bconstat(BC_AUX)) {
  1830.         key = Bconin(BC_AUX);
  1831.         if ( ct<128 && key!='@' && key!=10 && key!=13) {
  1832.             text[ct]=key;
  1833.             ct++;
  1834.          }
  1835.         if ( ct==128 || key=='@' ) {
  1836.             if(ct==0) { text[ct]='@'; ct++; }
  1837.             text[ct]=0;        
  1838.               recieving=0;
  1839.               }
  1840.              }
  1841.  
  1842.     /* time out in 5 seconds  */
  1843.     if ( ((timer2/CLK_TCK)-(timer1/CLK_TCK)) >4 ) {
  1844.             recieving=0;
  1845.         Bconout(BC_CON,7);
  1846.            }
  1847.  
  1848.  }
  1849. bad_cmd=1;     
  1850. }
  1851. /***********/
  1852. value(x_y)
  1853. int x_y;
  1854. {
  1855. float scale_ratio,round;
  1856. int num,v1,v2,v3,v4,ct,flg,key,recieving,x_screen,y_screen,plus_minus_flg;
  1857. unsigned long timer1, timer2,t1,t2;
  1858.  num=0; v1=0, v2=0, v3=0, v4=0, ct=0, flg=0, plus_minus_flg=0;
  1859.  
  1860. if(lp_flg==0) {
  1861. v_jmp:
  1862. do {
  1863.  
  1864. recieving=1;
  1865. timer1 = clock1();
  1866. while (recieving) {
  1867.         timer2 = clock1();
  1868.             if (Bconstat(BC_AUX)) {
  1869.                 key = Bconin(BC_AUX);
  1870.             recieving=0;
  1871.             }
  1872.  
  1873.     /* time out in 5 seconds */
  1874.     if ( ((timer2/CLK_TCK)-(timer1/CLK_TCK)) > 4 ) {
  1875.             recieving=0; num=0; key=0;
  1876.         Bconout(BC_CON,7);
  1877.            }
  1878.  
  1879.  }     
  1880.  
  1881. if (key<48 || key>57)  flg=1;
  1882.    else  {
  1883.     ct++;
  1884.     switch(ct) {
  1885.         case 1:  v1=key-48;
  1886.             break;
  1887.         case 2:  v2=key-48;
  1888.             break;
  1889.         case 3:  v3=key-48;
  1890.             break;
  1891.         case 4:  v4=key-48;
  1892.             break;
  1893.         default:  num=0;
  1894.         
  1895.         }
  1896.        } 
  1897. }  while ( flg == 0 );
  1898.  
  1899. switch(ct) {
  1900.     case 4: v3*=10; v2*=100; v1*=1000; num=v4+v3+v2+v1;
  1901.         break;
  1902.     case 3: v2*=10; v1*=100; num=v3+v2+v1;
  1903.         break;
  1904.     case 2: v1*=10; num=v2+v1;
  1905.         break;
  1906.     case 1: num=v1;
  1907.         break;
  1908.     default: num=0;
  1909.         
  1910.     }
  1911. if(g_s && x_y>0 && num>0) { /* If scaling set and desired do it! */
  1912.   if(g_s!=2) {
  1913.     if((g_res==2 || g_res==1) && x_y==1) x_screen=639;
  1914.     if(g_res==2 && x_y==2) y_screen=399;
  1915.     if((g_res==1 || g_res==0) && x_y==2) y_screen=199;
  1916.     if(g_res==0 && x_y==1) x_screen=319;
  1917.     scale_ratio=9999/num; 
  1918.     if(x_y==1) round=x_screen/scale_ratio;
  1919.     if(x_y==2) round=y_screen/scale_ratio;
  1920.     if(round-(int)round> .49) num=(int)round+1;
  1921.     if(round-(int)round< .5) num=(int)round;
  1922.   }
  1923.     /* g 2: option */
  1924.     if(g_s==2 && x_y==2 && g_res==2) num*=2;
  1925.  
  1926.     }
  1927. if(key=='_') { key=get_aux_char(); key=get_aux_char(); 
  1928.                 flg=0; goto v_jmp; }
  1929. if(key==120) { num= -32767; key=get_aux_char(); }
  1930. if(key==121) { num= -32766; key=get_aux_char(); }
  1931. if(key=='r') { num= -32765; key=get_aux_char(); }
  1932. /****  ,+CONSTANT,-CONSTANT, !CONSTANT ****/
  1933. if(key=='+') { plus_minus_flg=1; flg=0; goto v_jmp; }
  1934. if(key=='-') { plus_minus_flg=2; flg=0; goto v_jmp; }
  1935. if(key=='!') { plus_minus_flg=3; flg=0; goto v_jmp; }
  1936. if(plus_minus_flg==1) num= 0-num;
  1937. if(plus_minus_flg==2) num= 0-10000-num;
  1938. if(plus_minus_flg==3) num= 0-20000-num;
  1939.   } /* endif lp_flg */
  1940. if(lp_flg==1) { if (lp_eff_ct==0) lp_x=0;
  1941.  
  1942.                         if(lp_eff_ct==0) {
  1943.                          t1=clock1();
  1944.                          do {
  1945.                             t2=clock1();
  1946.                             if(Bconstat(BC_CON)) break;
  1947.                             } while (t2-t1<lp4);
  1948.                           }
  1949.  
  1950. if(lp_effect[lp_eff_ct] != -32767 && lp_effect[lp_eff_ct] != -32766) num=lp_effect[lp_eff_ct];
  1951. if(lp_effect[lp_eff_ct] == -32767 || lp_effect[lp_eff_ct] == -32766 || (lp_effect[lp_eff_ct]> -30000 && lp_effect[lp_eff_ct]<0))
  1952.                      {
  1953.                         lp_x++;
  1954.                         if(lp_2nd==0) lp_was=lp1;
  1955.                         if(lp_x<2 && lp_1st!=0) { lp1+=lp3; lp_2nd++;  
  1956.                         if(lp_2nd==1 && lp_type=='|') lp1=lp_was;
  1957.                         if(lp_2nd==2 && lp_type=='|') lp_2nd=0;
  1958.                         }
  1959.                          if(lp_effect[lp_eff_ct]< -29999) num=lp1;
  1960.                         lp_1st++;
  1961.                         if(lp_effect[lp_eff_ct]== -32766) {
  1962.                             if(lp5<lp2) num=lp2-lp1;
  1963.                             if(lp5>lp2) num=lp5-lp1;
  1964.                             if(lp5==lp2) num=0;
  1965.                         }
  1966.                         /* +CONSTANT =Step+CONSTANT */
  1967.                        if(num<0 && num> -10000) num=abs(num)+lp1;
  1968.  
  1969.                         /* -CONSTANT =Step-CONSTANT */
  1970.                        if(num< -9999 && num> -20000) {
  1971.                        num+=10000;
  1972.                        num=abs(num);
  1973.                        num=lp1-num;
  1974.                       }
  1975.                         /* !CONSTANT = CONSTANT-Step */
  1976.                        if(num< -19999 && num> -30000) {
  1977.                        num+=20000;
  1978.                        num=abs(num);
  1979.                        num-=lp1;
  1980.                       }
  1981.  
  1982.                      }
  1983.  
  1984.         /* Check for CTRL-C from user to abort LOOP */
  1985.                 if (Bconstat(BC_CON)) {
  1986.                 key = Bconin(BC_CON);
  1987.                 if (key == 3 || key==24) lp_flg=0;
  1988.              }
  1989.  
  1990.                 if(lp_no_prams==1 && lp_eff_ct==0) lp1+=lp3;
  1991.                 if(lp3>=1 && lp1>=lp2 && lp_eff_ct==(lp_num_prams-1)) lp_flg=0;
  1992.                 if(lp3<0 && lp1<=lp2 && lp_eff_ct==(lp_num_prams-1)) lp_flg=0;
  1993.                 if(lp_type!='@' && lp_flg==0 && lp_com=='W') lp_type='Z';
  1994.                 
  1995.                 lp_eff_ct++; 
  1996.                 if(lp_eff_ct>=lp_num_prams)  lp_eff_ct=0;
  1997.  
  1998.                 }
  1999. if(num== -32765 && r_lp==0) num=r_random();
  2000. bad_cmd=1;
  2001. return(num);
  2002. }  
  2003.  
  2004.  
  2005. /*************/
  2006. clip_set() {
  2007.  
  2008. int rez;
  2009.  
  2010. rez = Getrez();
  2011.  
  2012. if ( rez = 0 ) set_clip(0,0,319,199);
  2013. if ( rez = 1 ) set_clip(0,0,639,199);
  2014. if ( rez = 2 ) set_clip(0,0,639,399);
  2015. }
  2016.  
  2017. /************/
  2018.  
  2019. set_baud() { 
  2020.  
  2021. int x, b;
  2022.  
  2023. Cconws("\33E                               \33p SET BAUD \33q");
  2024. Cconws("\n\r             Note: not tested past 2400 baud");
  2025. Cconws("\n\n\r                [\33p1\33q] 300");
  2026. Cconws("\n\r                [\33p2\33q] 1200");
  2027. Cconws("\n\r                [\33p3\33q] 2400");
  2028. Cconws("\n\r                [\33p4\33q] 4800");
  2029. Cconws("\n\r                [\33p5\33q] 9600");
  2030. Cconws("\n\n\r                Select > ");
  2031.  
  2032. do {
  2033.   x=Bconin(2);
  2034.     } while( x< '1' || x> '5');
  2035.  
  2036. if(x=='1') b=9;
  2037. if(x=='2') b=7;
  2038. if(x=='3') b=4;
  2039. if(x=='4') b=2;
  2040. if(x=='5') b=1;
  2041.  
  2042. Rsconf(b,-1,-1,-1,-1,-1);
  2043. Cconws("\33E");
  2044. }
  2045. /*****************/
  2046. org_pallet() {
  2047.  
  2048. int reg;
  2049.  
  2050. /**** set original color palette ****/
  2051. reg=0;
  2052. do {
  2053.     vs_color(handle,reg, org_color[reg] );
  2054.     reg++;
  2055.  } while (reg != 16);
  2056.  
  2057. }
  2058.  /************/
  2059. file_find() {
  2060.  
  2061. /* search for filename return long length, filename is a global */
  2062. int i;
  2063. long saved;
  2064.  
  2065. struct {
  2066.     char    reserved[21];
  2067.     char    fattr;
  2068.     int     ftime;
  2069.     int     fdate;
  2070. unsigned long    fsize;
  2071.     char    fname[14];
  2072. } dumb;
  2073.  
  2074.  
  2075.     Cconws("\n\n\rExample  a:"); Bconout(BC_CON,92); 
  2076.     Cconws("best.ig");
  2077.     Cconws("\n\rEnter path and filename: ");
  2078.     filename[0] = 128;
  2079.     for(i=1;i<129;i++) filename[i]=' '; filename[129]='\0'; 
  2080.     Cconrs(filename); 
  2081.  
  2082. if(help==2) Cconws("\33E");
  2083.  
  2084. saved = Fgetdta();
  2085. Fsetdta(&dumb);
  2086. if (Fsfirst(&filename[2],0x10) == 0 ) {
  2087.  
  2088.         num_bytes = dumb.fsize;
  2089.         } else {
  2090.             num_bytes=0; }
  2091.  
  2092. if (num_bytes==0) Cconws("\n\n\rFile not found!\n\r");
  2093.  
  2094. }
  2095.  
  2096.  
  2097. /**************/
  2098. read_file( )  {
  2099.  
  2100. unsigned long int x2;
  2101.  
  2102.  
  2103. if ( bytes_left > 0 )  {
  2104.     if (bytes_left <= 4096L) {
  2105.       x2 = Fread(filehandle,bytes_left,filebuffer);
  2106.        if (x2 != bytes_left ) Cconws("\n\n\rError reading file!");
  2107.         }
  2108.  
  2109.     if (bytes_left > 4096L) {
  2110.        x2 = Fread(filehandle,4096L,filebuffer);
  2111.        if (x2 != 4096L) Cconws("\n\n\rError reading file!");
  2112.         }
  2113.     bytes_read = x2;
  2114.     bytes_left -= x2;
  2115.   }
  2116.     
  2117.  }
  2118.  
  2119. /*****************/
  2120. display_file()  {
  2121.  
  2122. int flag, u;
  2123.  
  2124.  
  2125.                 
  2126.         flag=5;
  2127.         f_ct=0;
  2128.           bytes_parsed=0;
  2129.         read_file();
  2130.         do {
  2131.  
  2132.             if ( f_ct == 4096 ) {
  2133.                 f_ct=0;
  2134.                 read_file();
  2135.                 }
  2136.     
  2137.          if((flag==0 && filebuffer[f_ct] !='#') || (flag==0 && help) ) {
  2138.             Bconout(BC_CON,'G');
  2139.             if(filebuffer[f_ct] !='G') Bconout(BC_CON,filebuffer[f_ct]);
  2140.                 }
  2141.     
  2142.                    if( flag != 0 && filebuffer[f_ct] !='G')
  2143.                 Bconout(BC_CON,filebuffer[f_ct]);
  2144.  
  2145.                 f_key = filebuffer[f_ct];
  2146.                 bytes_parsed ++;
  2147.                 f_ct ++;
  2148.                 flag++;
  2149.                 if ( flag > 30000 )   flag=5;
  2150.                 if (f_key =='G')  flag=0;
  2151.  
  2152.                 if ( f_key =='#' && flag == 1 && !help ) {
  2153.                   f_ct --;
  2154.                   bytes_parsed --;
  2155.                   do_file_graphics();
  2156.                   f_ct ++;
  2157.                   bytes_parsed ++;
  2158.                    }
  2159.  
  2160.                 if (Bconstat(BC_CON)) {
  2161.                  u = Bconin(BC_CON);
  2162.                  if (u==19) {
  2163.                   do {
  2164.                     if(Bconstat(BC_CON))
  2165.                      u=Bconin(BC_CON);
  2166.  
  2167.                       } while (u != 17 );
  2168.                     }            
  2169.  
  2170.                 if ( u==3 ) bytes_parsed=file_length+1;
  2171.  
  2172.                   }
  2173.  
  2174.  
  2175.            } while ( bytes_parsed < file_length );
  2176.  
  2177.  
  2178.  
  2179. }
  2180.  
  2181. /*******************/
  2182. do_file_graphics() {
  2183.  
  2184. int points[2], sides[4], rgb[3], rgb2[3];
  2185. static int current_palette[16] [3], previous_palette[16] [3];
  2186. int key, chain, rez, i, lp_ct;
  2187. int p1, p2, p3, val, v1, v2, v3, tries, out_of_range;
  2188. int v4,v5,v6,v7,pxy[8],settings[4],snd_num,snd_ele,*w2;
  2189. unsigned char rx, ry, is_gang='X', chain_gang[132];
  2190. unsigned long clock_t, timer1, timer2, rd;
  2191.  
  2192. do {
  2193.     key = get_char();
  2194.     chain = get_char();
  2195.  
  2196. if (key && chain) { 
  2197.   /** else it's the end of the file **/
  2198.  
  2199. if (key=='&') {  /*** LooP command settings ***/
  2200. /* & From,To,Step,Delay,COMMAND(, or |=Xor @=get_text)num_prams,x,x,const */
  2201.  
  2202.     lp_flg=0; 
  2203.     lp1=f_value(0); lp2=f_value(0); lp3=f_value(0); lp4=f_value(0);
  2204.     if(lp1>lp2){  lp_ct=lp3; lp3=0-lp_ct;  }
  2205.     if(lp3==0) lp3=1; 
  2206.     key=get_char(); lp_com=is_gang=key;
  2207.     if(is_gang=='>') { 
  2208.         f_get_text();
  2209.         for(v1=0; v1<128; v1++) chain_gang[v1]=text[v1];
  2210.      }
  2211.     lp_type=get_char(); lp_num_prams=f_value(0);
  2212.     if (lp_num_prams<1) lp_num_prams=1;
  2213.     if(lp_num_prams>2048) lp_num_prams=2048;
  2214.     lp_flg=0; /* 1st pass set array flags */
  2215.     lp5=lp1;
  2216.     r_lp=1; /* set random flg make flgs for rnd in array */
  2217.     for(lp_ct=0;lp_ct<lp_num_prams;lp_ct++) lp_effect[lp_ct]=f_value(0); 
  2218.     lp_eff_ct=0; lp_1st=0; lp_flg=1; lp_2nd=0; lp_no_prams=1;
  2219.     r_lp=0; /* set random back to normal operation */
  2220.     for(lp_ct=0;lp_ct<lp_num_prams;lp_ct++) {
  2221.     if (lp_effect[lp_ct]== -32767 || lp_effect[lp_ct]== -32766 || (lp_effect[lp_ct]> -30000 && lp_effect[lp_ct]<0)) lp_no_prams=0;
  2222.      }
  2223.  
  2224.     }
  2225.  
  2226. do {   /** do Loop for the '&' command **/
  2227.      bad_cmd=0;
  2228.      if(is_gang=='>') {
  2229.         v1=f_value(0);
  2230.         if(v1<0 || v1>127) v1=0;
  2231.         key=lp_com=chain_gang[v1];
  2232.      }
  2233.  
  2234. /******Graphics commands section ******/
  2235. if(key=='<') {  /*  GET_KEY_TRAN  < x,y,z:
  2236.                     x=0 tran key only
  2237.                     x=1 tran with CR
  2238.                     y=0 hot key input
  2239.                     y=1 CR required
  2240.                     y=2 MOUSE ZONE
  2241.                     z= output choice to screen? 1=yes 0=no 
  2242.                         2=yes toss, 3=no toss <- if toss no transmit
  2243.                         anything.
  2244.                     GET a keys remember till chain is broke
  2245.                     then transmit to host.  */
  2246.         mem_key_cr=f_value(0); val=f_value(0); v5=f_value(0);
  2247.         mem_key_flg=1; mem_key_ct=0;
  2248.             if(v5==2) mem_key_flg=0;
  2249.             if(v5==3) { v5=0; mem_key_flg=0; }
  2250.         do {
  2251.           if(val!=2) {
  2252.             v4=Bconin(BC_CON);
  2253.             if(v4==127 || v4==8 && mem_key_ct>0) mem_key_ct--;
  2254.             if(v4>31 && v4<127) {
  2255.                 if(mem_key_ct<129) {
  2256.                  mem_key_ct++;
  2257.                  mem_key[mem_key_ct]=v4;
  2258.                  if(v5) Bconout(BC_CON,mem_key[mem_key_ct]);
  2259.                 }
  2260.             } 
  2261.             if(v5 && v4==127 || v4==8) {
  2262.                     Bconout(BC_CON,27);  Bconout(BC_CON,'D');
  2263.                     Bconout(BC_CON,' '); 
  2264.                     Bconout(BC_CON,27);  Bconout(BC_CON,'D');
  2265.             }
  2266.         if(v4==13) val=0;
  2267.        }  /* endif (val!=2) */     
  2268. /************************************/
  2269.     if(val==2) { /* MOUSE ZONE for POINT and CLICK */
  2270.                  /* part of the "<" command. */
  2271.     zone_jmp:
  2272.         vq_mouse(handle,&v1,&v2,&v3);
  2273.             /* poll the mouse */
  2274.                 vqm_attributes(handle,settings);
  2275.                 vswr_mode(handle,3);
  2276.                 i=0; points[0]=10000; points[1]=10000;
  2277.                           
  2278.             do { vq_mouse(handle,&v1,&v2,&v3);
  2279.  
  2280.                 if( points[0] != v2  ||  points[1] != v3) {
  2281.                     if(i==1) v_pmarker(handle,1,points);
  2282.                  points[0]=v2; points[1]=v3; i=1;
  2283.                  v_pmarker(handle,1,points);
  2284.                  }
  2285.                 
  2286.                  } while(!v1);
  2287.  
  2288.             /* don't exit till button released */
  2289.             do  vq_mouse(handle,&p1,&p2,&p3); while(p1);
  2290.                  v_pmarker(handle,1,points);
  2291.                  vswr_mode(handle,settings[3]);
  2292.         v7=1;
  2293.         if(zone_loopback) v7=2;
  2294.         for(i=0;i<=47;i++) {
  2295.         if(v2>=zone[i][0] && v2<=zone[i][2] && v3>=zone[i][1] && v3<=zone[i][3] )
  2296.             { v7=0;    break; }
  2297.          }
  2298.         if(v7==1) i=47; /* default to last zone */
  2299.         if(v7==2) { Bconout(BC_CON,7); goto zone_jmp; }
  2300.         mem_key_ct=zone_cmds[i][0];
  2301.         for(v6=1;v6<mem_key_ct+1;v6++) mem_key[v6]=zone_cmds[i][v6];         
  2302.         val=0;
  2303.        } /* endif (val==2) */
  2304.  
  2305.         } while(val>0);
  2306. }
  2307.  
  2308. if(key=='N') {  /*  NOISE   N x,num_bytes */
  2309.                 /* x=0 load midi buff */
  2310.                 /* x=1 load and execute */
  2311.                 /* x=2 execute buff, NO num_bytes given */
  2312.                 /* x=3 load buff for CHIP */
  2313.                 /* x=4 load buff for chip and exe */
  2314.                 /* x=5 exe buff with chip commands */
  2315.             val=f_value(0);
  2316.             if(val==2 || val==5) v1=midi_len;
  2317.     if(val!=2 && val!=5) {
  2318.             v1=f_value(0);
  2319.             midi_len=v1;
  2320.             for(p1=0;p1<v1;p1++) {
  2321.                  ig_midi[p1]=get_char();
  2322.                 if(Bconstat(BC_CON)) { 
  2323.                         v7=Bconin(BC_CON);
  2324.                  if(v7==3 || v7==24) { midi_len=0; val=0; break; }
  2325.                  }
  2326.              }
  2327.             if(val==0 || val>2) { p3=midi_on; midi_on=0; }
  2328.      }
  2329.     if(midi_on && val<3) {
  2330.             for(p2=1;p2<v1;p2+=2) {
  2331.                 if(Bconstat(BC_CON)) { 
  2332.                         v7=Bconin(BC_CON);
  2333.                  if(v7==3 || v7==24) break;
  2334.                  if(v7=='+') p2++;
  2335.                  }
  2336.                  if(p2>10000) p2=10000;
  2337.             while(!Bcostat(3));
  2338.             v2=ig_midi[p2-1];
  2339.             /* MIDI out */
  2340.             Bconout(3,v2);
  2341.             timer1=clock1();
  2342.             /* do timing */
  2343.             while(clock1()-timer1<ig_midi[p2]);
  2344.              }
  2345.      } /*endif midi_on*/
  2346.     if(val==0 || val>2)  midi_on=p3;
  2347.     if(val==4 || val==5 && v1>5) {
  2348.      for(p1=0;p1<v1;p1+=6) {
  2349.                 if(Bconstat(BC_CON)) { 
  2350.                         v7=Bconin(BC_CON);
  2351.                  if(v7==3 || v7==24) break;
  2352.                  if(v7=='+') p1++;
  2353.                  }
  2354.                  if(p1>10000) p1=10000;
  2355.  
  2356.         play_note(ig_midi[p1],ig_midi[p1+1],ig_midi[p1+2],ig_midi[p1+3],ig_midi[p1+4],ig_midi[p1+5]);    
  2357.       }
  2358.      }
  2359.  }
  2360. if (key=='X') {  /*  extended commands section  */
  2361.          /*  extended commands are identified by a 
  2362.              X and a number value 0 thru 9999.  This
  2363.              allows 10,000 new commands to be introduced.
  2364.              use the lower case x for adding your 
  2365.              own extended commands. */
  2366.           val=f_value(0);
  2367. /*----------------------------------------------------------------------------*/
  2368.         /* 0, left_x,left_y, range_x,range_y, num_dots    spray paint */
  2369.         /*  the ranges can only be 0 thru 255 */
  2370.             if(val==0) {
  2371.                 p1=f_value(1); p2=f_value(2); v1=f_value(1);
  2372.                 v2=f_value(2); v3=f_value(0);
  2373.                 for(p3=0;p3<v3;p3++) {
  2374.                 rd=Random();
  2375.                 rx=(char)rd;
  2376.                 rd=Random();
  2377.                 ry=(char)rd;
  2378.                 tries=0;            
  2379.                 do {
  2380.                     tries++;
  2381.                     out_of_range=0;
  2382.                     if(rx>v1) { out_of_range=1;
  2383.                         rd=Random(); rx=(char)rd; }
  2384.                     if(ry>v2) { out_of_range=1;
  2385.                         rd=Random(); ry=(char)rd; }
  2386.                   if(tries>8) { out_of_range=0; rx=0; ry=0; }
  2387.                    } while(out_of_range);
  2388.             points[0]=p1+rx;    points[1]=p2+ry;
  2389.             v_pmarker(handle,1,points);
  2390.                 }
  2391.             }
  2392.             /***** end of spray paint *****/    
  2393.  
  2394.     /***************************Setcolor register**************************/
  2395.         /*  X 1,register,value       
  2396.             register 0-15  value 0-1911 */
  2397.         if(val==1) {   /*  Setcolor register with Xbios */
  2398.                    /*  Allow changing of registers without
  2399.                    using VDI */
  2400.  
  2401.             p1=f_value(0);  p2=f_value(0);
  2402.             if(p1>15) p1=15;
  2403.         /*    if(p2>1911) p2=1911;    Kill may allow 4096 colors */
  2404.             Setcolor(p1,p2);
  2405.  
  2406.         }
  2407.  
  2408.     /******** Set RANDOM from to range *******/
  2409.         /* X 2,from,to  */
  2410.     if(val==2) {
  2411.                 rnd_f=f_value(0);  rnd_t=f_value(0);
  2412.                 if(rnd_f<0) rnd_f=0;
  2413.                 if(rnd_t<rnd_f) rnd_t=rnd_f+1;
  2414.                 }
  2415.  
  2416.  /**** Right button tran command string ***
  2417.    X 3,operation|,CR?,number of chars in tran string,tran string. */
  2418.     if(val==3) {
  2419.             v1=f_value(0);
  2420.             if(v1>2) v1=0;
  2421.             if(v1==0) x_r_but=0; /* X 3,OFF? */
  2422.             if(v1==1) { /* X 3,ON,CR? */
  2423.                 x_r_but=1; r_but_tran[81]=f_value(0);
  2424.              }
  2425.             if(v1==2) { /*X 3,2,ON,CR?,string len,string */
  2426.              v4=f_value(0);
  2427.              if(v4==0) x_r_but=0; else x_r_but=1;
  2428.              r_but_tran[81]=f_value(0);
  2429.              r_but_tran[0]=f_value(0);
  2430.              if(r_but_tran[0]>80) r_but_tran[0]=80;
  2431.              if(r_but_tran[0]<1) r_but_tran[0]=1;
  2432.              for(v2=1;v2<=r_but_tran[0];v2++)
  2433.                  r_but_tran[v2]=get_char();
  2434.              v3=get_char(); /* dead get for seperator */
  2435.              }        
  2436.         }
  2437.  
  2438. /************ LOAD ZONE DATA FOR POINT & CLICK *******/
  2439.         if(val==4) {  /* zone_num,up_left_x,up_left_y,
  2440.                          lower_right_x,lower_right_y,
  2441.                          cmd_string_len,cmd_string: */
  2442.             v1=f_value(0);  if(v1>47 && v1!=9999 && v1!=9998 && v1!=9997) v1=47; /* zone_num */
  2443.  
  2444.         /*  if X 4,9999: zero zones  */
  2445.         if(v1==9999) for(p1=0;p1<48;p1++) {
  2446.                         zone[p1][0]=-1;
  2447.                         zone[p1][1]=-1;
  2448.                         zone[p1][2]=-1;
  2449.                         zone[p1][3]=-1;
  2450.                         }
  2451.         /* if X 4,9998:  SET ZONE loopback on invalid selection */
  2452.         if(v1==9998) zone_loopback=1; /*ON*/
  2453.         if(v1==9997) zone_loopback=0; /*OFF*/
  2454.  
  2455.           if(v1<9997) {
  2456.             zone[v1][0]=f_value(1); /* up_left_x */
  2457.             zone[v1][1]=f_value(2); /* up_left_y */
  2458.             zone[v1][2]=f_value(1); /* lower_right_x */
  2459.             zone[v1][3]=f_value(2); /* lower_right_y */
  2460.  
  2461.             v2=f_value(0);  if(v2>80) v2=80;  /* cmd_string_len */
  2462.             if(v2<1) v2=1;
  2463.             zone_cmds[v1][0]=v2;
  2464.             for(v3=1;v3<=zone_cmds[v1][0];v3++)
  2465.                 zone_cmds[v1][v3]=get_char();
  2466.             v4=get_char(); /* dead get for seperator */
  2467.  
  2468.           } /* endif v1<9997 */
  2469.          }
  2470.  
  2471.  
  2472. /************   XON XOFF shutdown ***************/
  2473.         if(val==5) { /* 0=off
  2474.                         1=on */
  2475.                      /* 2=set xon xtimes */
  2476.                      /* 3=set xoff xtimes*/
  2477.             x_on=f_value(0);
  2478.             if(lp_flg) x_on=1;
  2479.  
  2480.             if(x_on==2) { 
  2481.                 x_on_char=f_value(0);
  2482.                 x_times=f_value(0);
  2483.              }
  2484.             if(x_on==3) {
  2485.                 x_off_char=f_value(0);
  2486.                 x_times_x=f_value(0);
  2487.              }
  2488.             if(x_on>3) {
  2489.                  x_on_char=17; x_off_char=19;
  2490.                  x_times=1; x_times_x=1;
  2491.              }
  2492.  
  2493.             }
  2494.  
  2495.  
  2496. /************  LEFT MOUSE BUTTON AS CR\LF  ON OFF  ****/
  2497.         if(val==6) {  /* 0= OFF  1=ON CR  2=ON CR\LF */
  2498.             mouse_CR=f_value(0);
  2499.         }
  2500.  
  2501. /******  X 7 left BLANK for now   ******/
  2502.  
  2503.  /******* X 8,from,to,times,delay:   Color Rotation *******/
  2504.         if(val==8) {
  2505.           v1=f_value(0);  v2=f_value(0);  v3=f_value(0); v4=f_value(0);
  2506.  
  2507.          if(v1==1 && v2==1 && v3==1 && v4==1) { /* store palette */
  2508.           for(v5=0; v5<=15; v5++) 
  2509.             vq_color(handle, v5, 0, previous_palette[v5]);
  2510.            }
  2511.  
  2512.           if(v1>15 || v1<0) v1=15;
  2513.           if(v2>15 || v2<0) v2=15;
  2514.  
  2515.           if(v3!=0 && v1!=v2) { /* don't rotate if times= 0 or from= to */
  2516.  
  2517.             for(v6=0; v6<=v3; v6++) {
  2518.              if(v1<v2) {     /* rotate right */
  2519.                 vq_color(handle,v2,0, rgb);
  2520.                 for(v5=v2; v5>=v1; v5--) {
  2521.                     vq_color(handle,v5-1,0,rgb2);
  2522.                     Vsync();
  2523.                      vs_color(handle,v5,rgb2);
  2524.                 }
  2525.                     Vsync();
  2526.                     vs_color(handle,v1,rgb);
  2527.              }
  2528.  
  2529.       if(v1>v2) {     /* rotate left */
  2530.         vq_color(handle,v2,0,rgb);
  2531.         for(v5=v2; v5<=v1; v5++) { 
  2532.         vq_color(handle,v5+1,0,rgb2);
  2533.         Vsync();
  2534.         vs_color(handle,v5,rgb2);
  2535.         }
  2536.         Vsync();
  2537.         vs_color(handle,v1,rgb);
  2538.       }
  2539.       delay (v4);
  2540.       if(Bconstat(BC_CON)) {Bconin(BC_CON); v6=v3+1; }
  2541.  
  2542.             } /* next v6 */
  2543.  
  2544.           }
  2545.           if(v3==0) {     /* restore previous palette */
  2546.             for(v5=0; v5<=15; v5++) vs_color(handle,v5,previous_palette[v5]);
  2547.           }
  2548.  
  2549.     } /* end of X 8 routine */
  2550.  
  2551.     } 
  2552.  
  2553. if(key=='?') {  /* The INQUIRE command. */
  2554.     val=f_value(0);
  2555.     while(Bcostat(BC_AUX)==0);    
  2556.  
  2557.     if(val==0) {    /* VERSION */
  2558.         Bconout(BC_AUX,'2'); Bconout(BC_AUX,'.');
  2559.         Bconout(BC_AUX,'1'); Bconout(BC_AUX,'7');
  2560.      } 
  2561.     if(val==1) { /* ? 1,mouse?
  2562.                     CURSOR POSITION send X(column) & Y(row) & Mbutton
  2563.                    back in ASCII character form,-32 offset to
  2564.                    0-79, 0-24, 0-3 */
  2565.  
  2566.             v4=f_value(0);
  2567.             /* CURSOR MOVEMENT FROM MOUSE if 2nd pram set*/
  2568.     vq_mouse(handle,&butdown,&mx,&my);
  2569.     if(v4){
  2570.             do {
  2571.                 vq_mouse(handle,&butdown,&mx,&my);
  2572.                 if(mx<v2) Cconws("\33D");
  2573.                 if(mx>v2) Cconws("\33C");
  2574.                 if(my<v3) Cconws("\33A");
  2575.                 if(my>v3) Cconws("\33B");        
  2576.                 p3=butdown; v2=mx; v3=my;
  2577.                 } while(!p3);
  2578.             do { vq_mouse(handle,&v1,&v2,&v3);  } while (v1);
  2579.      }
  2580.  
  2581.         vq_curaddress(handle,&p2,&p1); p3=butdown;
  2582.         p2+=31; p1+=31; p3+=32;
  2583.         Bconout(BC_AUX,p1); Bconout(BC_AUX,p2); Bconout(BC_AUX,p3);
  2584.      }
  2585.  
  2586.     if(val==2) { /* ? 2,x  Send back mouse coordinates, button */
  2587.         v4=f_value(0);
  2588.         vq_mouse(handle,&v1,&v2,&v3);
  2589.         if(v4) {
  2590.             /* poll the mouse */
  2591.                 vqm_attributes(handle,settings);
  2592.                 vswr_mode(handle,3);
  2593.                 i=0; points[0]=10000; points[1]=10000;
  2594.                           
  2595.             do { vq_mouse(handle,&v1,&v2,&v3);
  2596.  
  2597.                 if( points[0] != v2  ||  points[1] != v3) {
  2598.                     if(i==1) v_pmarker(handle,1,points);
  2599.                  points[0]=v2; points[1]=v3; i=1;
  2600.                  v_pmarker(handle,1,points);
  2601.                  }
  2602.                 
  2603.                  } while(!v1);
  2604.  
  2605.             /* don't exit till button released */
  2606.             do  vq_mouse(handle,&p1,&v2,&v3); while(p1);
  2607.                  v_pmarker(handle,1,points);
  2608.                  vswr_mode(handle,settings[3]);
  2609.  
  2610.          }
  2611.         /* make mouse values transmit in ascii */
  2612.         v1+=48; v7=0;
  2613.         do {
  2614.             if(v2>9999) v2=9999;
  2615.             if(v7==1) v2=v3;
  2616.             if(v2>999) { v6=(v2/1000); Bconout(BC_AUX,v6+48); v2-=(v6*1000);
  2617.                 if(v2<100) Bconout(BC_AUX,'0'); }
  2618.             if(v2>99)  { v6=(v2/100); v6; Bconout(BC_AUX,v6+48); v2-=(v6*100);
  2619.                 if(v2<10) Bconout(BC_AUX,'0'); }
  2620.             if(v2>9)   { v6=(v2/10); Bconout(BC_AUX,v6+48); v2-=(v6*10); }
  2621.             if(v2>0)   { v6=v2; Bconout(BC_AUX,v6+48); } else  Bconout(BC_AUX,'0');
  2622.             v7++; Bconout(BC_AUX,',');
  2623.             } while(v7<2);
  2624.             Bconout(BC_AUX,v1); Bconout(BC_AUX,':');
  2625.      }
  2626.  
  2627.     if(val==3) { /* send the host the current rez */
  2628.         i=Getrez();
  2629.         i+=48;
  2630.         Bconout(BC_AUX,i); Bconout(BC_AUX,':');
  2631.      }
  2632.  
  2633.     }
  2634.  
  2635. if (key=='G') { /* Grab a piece of the screen. */
  2636. /* G to_screen_or_mem,mode,xs1,ys1,| xs2,ys2, |  xd1,yd1 */
  2637.     vq_extnd(handle,1,work_out);
  2638.     val=f_value(0); v7=f_value(0);
  2639.     v1=f_value(1); v2=f_value(2); 
  2640.  
  2641.     if(val==2) { v3=(vd3-vd1)+v1; v4=(vd4-vd2)+v2; }
  2642.  
  2643.     if(val==1 || val==0 || val==3) { v3=f_value(1); v4=f_value(2); }
  2644.     
  2645.     if(val==0 || val==3) { /* if blit to screen get dest area */ 
  2646.         v5=f_value(1); v6=f_value(2); 
  2647.      }
  2648.  
  2649.     p1=Getrez();
  2650.     if(p1>2) p1=0;  /* limit to ST modes */
  2651.     if(p1==0) {
  2652.      if(v1>319) v1=319;
  2653.      if(v3>319) v3=319;
  2654.      if(v5>319) v5=319;
  2655.      }
  2656.     if(p1==0 || p1==1) {
  2657.      if(v2>199) v2=199;
  2658.      if(v4>199) v4=199;
  2659.      if(v6>199) v6=199;
  2660.      }
  2661.     if(p1==2) {
  2662.      if(v2>399) v2=399;
  2663.      if(v4>399) v4=399;
  2664.      if(v6>399) v6=399;
  2665.      }
  2666.     if(p1==1 || p1==2) {
  2667.      if(v1>639) v1=639;
  2668.      if(v3>639) v3=639;
  2669.      if(v5>639) v5=639;
  2670.      }
  2671.  
  2672.     pxy[0]=v1; pxy[4]=v1;
  2673.     pxy[1]=v2; pxy[5]=v2;
  2674.     pxy[2]=v3; pxy[6]=v3;
  2675.     pxy[3]=v4; pxy[7]=v4; 
  2676.     if(val==1) { vd1=v1; vd2=v2; vd3=v3; vd4=v4; }
  2677.     if(val==2) { pxy[0]=vd1; pxy[1]=vd2; pxy[2]=vd3; pxy[3]=vd4;
  2678.                  pxy[6]=(vd3-vd1)+v1; pxy[7]=(vd4-vd2)+v2; 
  2679.      }
  2680.  
  2681.  
  2682.  
  2683.     /* from 0=screen to screen, 1=screen to mem, 2=mem to screen */
  2684.     if(val>3) val=3;
  2685.     sourceMFDB.image=0L;
  2686.     destMFDB.image=bitblt_storage;
  2687.     destMFDB.width=vd3-vd1;
  2688.     destMFDB.height=vd4-vd2;
  2689.     destMFDB.wordw=((vd3-vd1)/16)+1;
  2690.     if(destMFDB.wordw>40) destMFDB.wordw=40;
  2691.     destMFDB.flag=0;
  2692.     destMFDB.planes=work_out[4];
  2693.  
  2694.         
  2695.     if(val==0 || val==3) { /* set dest area for a blit to screen */
  2696.         pxy[4]=v5; pxy[5]=v6; pxy[6]=(v3-v1)+v5; pxy[7]=(v4-v2)+v6;
  2697.       }
  2698.  
  2699.     if(v7>15) v7=3;  /* set to replace mode if err */
  2700.    for(i=0;i<8;i++) if(pxy[i]<0) pxy[i]=0;
  2701.         if(val==0) { destMFDB=sourceMFDB;
  2702.             vro_cpyfm(handle,v7,pxy,&sourceMFDB,&destMFDB);
  2703.           }
  2704.         if(val==1)     vro_cpyfm(handle,v7,pxy,&sourceMFDB,&destMFDB);
  2705.         if(val==2 || val==3)     vro_cpyfm(handle,v7,pxy,&destMFDB,&sourceMFDB);
  2706.     }
  2707.  
  2708. if (key=='I') {  /* I x    INITIALIZE  */
  2709.          /* inits to what ever the attributes of the calling 
  2710.             program or desktop were set to. */
  2711.          /* x = 0 init pallet and attributes */
  2712.          /* x = 1 init pallet  ONLY */
  2713.          /* x = 2 init attributes  ONLY  */
  2714.          /* x = 3 inti IG default pallete */ 
  2715.           val=f_value(0);
  2716.           if(val>3) val=0;
  2717.           if(val==0) { org_pallet(); reset_attributes(); }
  2718.           if(val==1)  org_pallet();
  2719.           if(val==2)  reset_attributes();
  2720.           if(val==3)  for(val=0; val<16; val++) vs_color(handle,val,sys_color[val] );
  2721.         } 
  2722.  
  2723. if (key=='A') {   /* A t p b   fill ATTRIBUTES  */
  2724.                   /*  t=type (0-3)  0=hollow 1=solid 2=pattern 3=hatch */
  2725.           /*  p=pattern (1-24) works only with pattern & hatch types */
  2726.           /*  b=border 0=no border any other value yields a border */
  2727.  
  2728.            val=f_value(0); p1=f_value(0); p2=f_value(0);
  2729.            if (val>3) val=0;
  2730.            vsf_interior(handle,val);
  2731.                    vsf_style(handle,p1);
  2732.            vsf_perimeter(handle,p2);
  2733.         }
  2734.  
  2735. if (key=='B') {  /*  B tlx tly brx bry r    BAR (rectangle) filled */
  2736.          /* tl=topleft corner x y cords. */
  2737.          /* br=bottom right x y cords. */
  2738.          /* r=rounded corners? (1=yes 0=no) */
  2739.  
  2740.            sides[0]=f_value(1); sides[1]=f_value(2);
  2741.            sides[2]=f_value(1); sides[3]=f_value(2);
  2742.            val=f_value(0);
  2743.            if ( ! val ) v_bar(handle,sides);
  2744.            if ( val )   v_rfbox(handle,sides);
  2745.         }
  2746.  
  2747. if (key=='C') {  /*  C x pen    -set polymarker, line, fill */
  2748.          /*  and "WRITTEN" text color */
  2749.          /* where x=(0-4) 0=marker 1=line 2=fill 3=text */
  2750.          /* pen = (0 - 15) VDI pen not color register */
  2751.  
  2752.            p1=f_value(0);
  2753.                    val=f_value(0); 
  2754.            if (val>15) val=0;
  2755.            if (p1>3) p1=0;
  2756.         if(p1==0)   vsm_color(handle,val); 
  2757.         if(p1==1)   vsl_color(handle,val);
  2758.         if(p1==2)   vsf_color(handle,val);
  2759.         if(p1==3)   vst_color(handle,val); 
  2760.         }
  2761.          
  2762. if (key=='D')  {   /* D x y     DRAWTO  */
  2763.            /* use P x y to set starting point and be sure */
  2764.            /* type is T 1 1 1 if you want a pixel point */
  2765.  
  2766.            lines[0]=lines[2];  lines[1]=lines[3];
  2767.            lines[2]=f_value(1); lines[3]=f_value(2);
  2768.            v_pline(handle,2,lines);
  2769.            lines[0]=lines[2];  lines[1]=lines[3];
  2770.         }
  2771.  
  2772. if (key=='E')  {  /* E font size rotation EFFECTS for "WRITTEN" text */
  2773.           /* font(1,2,4,8,16)  size(8,9,10,16,18,20 (in points 1/72") */
  2774.           /* rotation (0-4) = *90 degrees */
  2775.  
  2776.              p1=f_value(0); p2=f_value(0); p3=f_value(0);
  2777.              vst_effects(handle,p1);
  2778.              if (p3>4) p3=0;
  2779.              p3 *=900;
  2780.              vst_rotation(handle,p3);
  2781.              if (p2<8) p2=8;
  2782.              if (p2>20) p2=20;
  2783.              vst_point(handle,p2,&p1,&p3,&v1,&v2);
  2784.         }
  2785.  
  2786. if (key=='F')  {  /* F x y   FLOOD FILL color replace mode */
  2787.            p1=f_value(1); p2=f_value(2);
  2788.            v_contourfill(handle,p1,p2,-1);
  2789.         }
  2790.  
  2791. if (key=='H')  {  /* H x    HOLLOW ( frames ) */
  2792.           /*   x=1 on    x=0 off */
  2793.  
  2794.              val=f_value(0);
  2795.              if ( val>1 ) val=1;
  2796.              if ( val==1 ) {
  2797.             vsf_interior(handle,0);
  2798.             vswr_mode(handle,2);
  2799.             vsf_perimeter(handle,1);
  2800.             }
  2801.               if ( val == 0 ) {
  2802.             vsf_interior(handle,1);
  2803.             vswr_mode(handle,1);
  2804.             vsf_perimeter(handle,0);
  2805.             }
  2806.         }
  2807.  
  2808. if (key=='J')  {  /* J x y xradius yradius begin_angle end_angle */
  2809.           /* ELLIPTICAL ARC */
  2810.            p1=f_value(1); p2=f_value(2); p3=f_value(1);
  2811.            v1=f_value(2); v2=f_value(0); v3=f_value(0);
  2812.            v2 *= 10;   v3 *= 10;            
  2813.            v_ellarc(handle,p1,p2,p3,v1,v2,v3);
  2814.         }
  2815. if (key=='K')  {  /* K x y radius begin_angle end_angle    ARC   */
  2816.           p1=f_value(1); p2=f_value(2); p3=f_value(1);
  2817.           v1=f_value(0); v2=f_value(0);
  2818.           v1 *= 10;  v2 *= 10;
  2819.           v_arc(handle,p1,p2,p3,v1,v2);
  2820.         }
  2821.  
  2822. if (key=='Z')  { /* Z x_up_left y_up_left x_low_right y_low_right */
  2823.          /* FILLED RECTANGLE */
  2824.          sides[0]=f_value(1); sides[1]=f_value(2);
  2825.          sides[2]=f_value(1); sides[3]=f_value(2);
  2826.          vr_recfl(handle,sides);
  2827.         }
  2828.  
  2829. if (key=='U')  {  /* U left_edge top_edge right_edge bottom_edge fill_flag  */
  2830.           /* ROUNDED RECTANGLE */
  2831.           sides[0]=f_value(1); sides[1]=f_value(2);
  2832.           sides[2]=f_value(1); sides[3]=f_value(2);
  2833.           val=f_value(0);
  2834.           if (val==0) v_rbox(handle,sides);
  2835.           if (val>0 ) v_rfbox(handle,sides);
  2836.         }
  2837.             
  2838. if (key=='L')  {   /* L x y xEND yEND draw a line */
  2839.            lines[0]=f_value(1); lines[1]=f_value(2);
  2840.            lines[2]=f_value(1); lines[3]=f_value(2);
  2841.            v_pline(handle, 2, lines);    
  2842.         }
  2843.             
  2844. if (key=='M')  {   /* M x   graphics drawing MODE  */
  2845.            /* 1=replace, 2=Transparent, 3=XOR, 4=reverse transparent */
  2846.            val=f_value(0);
  2847.            if (val<1 || val>4) val=1;
  2848.            vswr_mode(handle,val);
  2849.         } 
  2850. if (key=='g')  {  /* g x   Set graphics scaling coordinates */
  2851.             val=f_value(0);
  2852.             if (val<0 || val>2) val=0;
  2853.                 g_s=val; g_res=Getrez();
  2854.         } 
  2855.  
  2856. if (key=='O')  {  /* O x y radius    CIRCLE  */
  2857.  
  2858.            p1=f_value(1); p2=f_value(2); p3=f_value(1);
  2859.            v_circle(handle,p1,p2,p3);
  2860.         }
  2861.  
  2862. if (key=='P')  {    /*   P x y  polymarker plot */
  2863.             points[0]=f_value(1); points[1]=f_value(2);
  2864.             v_pmarker(handle,1,points);
  2865.              lines[2]=points[0]; lines[3]=points[1];      
  2866.         }
  2867.  
  2868. if (key=='Q')  {  /* Q x y xradius yradius  OVAL (ellipse) */
  2869.  
  2870.              p1=f_value(1); p2=f_value(2); p3=f_value(1); val=f_value(2);
  2871.              v_ellipse(handle,p1,p2,p3,val);
  2872.         }
  2873.  
  2874. if (key=='R')  {   /* R x p   set resolution 0-1   sys pallete 0-2 */
  2875.            val=f_value(0); p1=f_value(0);
  2876.                    rez=Getrez();
  2877.                    if ( val< 0 || val>1 ) val=rez; 
  2878.             if (rez != 2 && rez!=val) {
  2879.                 if(val==0) rez_change_low();
  2880.                 if(val==1) rez_change_med();
  2881.             }  /* Setscreen(-1L,-1L,val); */
  2882.  
  2883.            clip_set();
  2884.            if( p1==2 ) for(val=0; val<16; val++) vs_color(handle,val,sys_color[val] );
  2885.            if( p1==1 )  for(p1=0; p1<16; p1++) vs_color(handle,p1,org_color[p1]);
  2886.                    }
  2887.  
  2888. if (key=='S')  {   /* S pen red green blue   pen(0-15)  rgb(0-7) */
  2889.            /* SET PEN COLOR */
  2890.           val=f_value(0); rgb[0]=f_value(0);
  2891.            rgb[1]=f_value(0); rgb[2]=f_value(0);  
  2892.            if (val>15) val=0; 
  2893.                for(p1=0; p1<3; p1++) {
  2894.             p2=rgb[p1];
  2895.             switch(p2) {
  2896.                 case 1: rgb[p1]=142;
  2897.                     break;
  2898.                 case 2: rgb[p1]=285;
  2899.                     break;
  2900.                 case 3: rgb[p1]=428;
  2901.                     break;
  2902.                 case 4: rgb[p1]=571;
  2903.                     break;
  2904.                 case 5: rgb[p1]=714;
  2905.                     break;
  2906.                 case 6: rgb[p1]=857;
  2907.                     break;
  2908.                 case 7: rgb[p1]=1000;
  2909.                     break;
  2910.                 default: rgb[p1]=0;
  2911.                     break;
  2912.               }
  2913.               }
  2914.        vs_color(handle,val,rgb);     
  2915.         }
  2916.  
  2917. if (key=='T')  {   /* type of polymarker(1-6) and height(y*11) y=(1-8) */
  2918.            /* type of line(1-6) and thickness(1-40) */
  2919.            /* 1 for marker  2 for line */
  2920.                    /* G#T 1 3 8  marker     G#T 2 1 40 line */
  2921.            /*  T 2 1 50 (to 54) arrowhead endlines */
  2922.            /*  T 2 1 60 (to 64) rounded endlines */
  2923.            /*  T 2 1 0   square endlines */
  2924.            p1=f_value(0);                     
  2925.                    if ( p1<1 || p1>2 ) break;      
  2926.                      p2=f_value(0);          
  2927.            if ( p2<1 || p2>6 ) p2=1;       
  2928.  
  2929.                    if ( p1 == 1 ) {               
  2930.              p3=f_value(0);            
  2931.            if (p3<1 || p3>8 ) p3=1;      
  2932.             vsm_type(handle,p2);         
  2933.                     vsm_height(handle,p3*11);      
  2934.             }
  2935.                    
  2936.            if (p1==2) {              
  2937.             p3=f_value(0);
  2938.             
  2939.             if (p3<42 && p3>0) {          
  2940.               if (p2>1) p3=1; 
  2941.               vsl_type(handle,p2); 
  2942.               vsl_width(handle,p3);
  2943.             }
  2944.             if (p3==0)   vsl_ends(handle,0,0);
  2945.             if (p3==50)  vsl_ends(handle,1,1);
  2946.             if (p3==51)  vsl_ends(handle,1,0);
  2947.             if (p3==52)  vsl_ends(handle,0,1);
  2948.             if (p3==53)  vsl_ends(handle,1,2);
  2949.             if (p3==54)  vsl_ends(handle,2,1);
  2950.  
  2951.             if (p3==60)  vsl_ends(handle,2,2);
  2952.             if (p3==61)  vsl_ends(handle,2,0);
  2953.             if (p3==62)  vsl_ends(handle,0,2);
  2954.             if (p3==63)  vsl_ends(handle,2,1);
  2955.             if (p3==64)  vsl_ends(handle,1,2);
  2956.  
  2957.             }
  2958.           } 
  2959.  
  2960. if (key=='V')  {  /*  V x y radius beginangle endangle     PIESLICE  */
  2961.  
  2962.               p1=f_value(1); p2=f_value(2); p3=f_value(1);
  2963.               v1=f_value(0); v2=f_value(0);
  2964.               v1 *=10; v2 *=10;
  2965.               v_pieslice(handle,p1,p2,p3,v1,v2);
  2966.         }
  2967.  
  2968. if (key=='W')  {  /* W x y string    "WRITE" text to x y coord. */
  2969.              p1=f_value(1); p2=f_value(2); 
  2970.              f_get_text();
  2971.              v_gtext(handle,p1,p2,text);
  2972.         }
  2973.  
  2974. if (key=='Y')  {  /* Y x y xradius yradius beginangle endangle  OVAL-PIESLICE */
  2975.              p1=f_value(1); p2=f_value(2); p3=f_value(1);
  2976.              v1=f_value(2); v2=f_value(0); v3=f_value(0);
  2977.              v2 *=10; v3 *=10;
  2978.              v_ellpie(handle,p1,p2,p3,v1,v2,v3);
  2979.         }
  2980.  
  2981. if(key=='n')   {  /* n,  PLAY_NOTE */
  2982.                /* Musical Note Routine has 6 parameters p1-p6 */
  2983.                 /* 1 = effect number(1-19)    2 = voice number(0-2) */
  2984.                 /* 3 = volume(0-15)           4 = pitch(0-255)  */
  2985.                 /* 5 = pause in 200ths sec (0-9999) */
  2986.                 /* 6 = stop sound type (0-4)   */
  2987.             v1=f_value(0); v2=f_value(0); v3=f_value(0); v4=f_value(0);
  2988.             v5=f_value(0); v6=f_value(0);
  2989.             play_note(v1,v2,v3,v4,v5,v6);
  2990.  }
  2991.  
  2992. if (key=='t')  {  /* t x     TIME */
  2993.           /* pause BBS by sending a cntrl-s and time it for x seconds */
  2994.           /* then send a ctrl-q     30 second max */
  2995.            val=f_value(0);
  2996.            if(val>30) val=30;
  2997.  
  2998.            timer1 = clock1();
  2999.  
  3000.            do {
  3001.             timer2 = clock1();
  3002.  
  3003.             if(Bconstat(BC_CON)) {
  3004.                 Bconin(BC_CON);
  3005.                 val=0;
  3006.               }
  3007.  
  3008.                   } while ( ((timer2/CLK_TCK)-(timer1/CLK_TCK)) < val );    
  3009.  
  3010.          }
  3011.  
  3012. if (key=='m')  {   /* m x t   CURSOR MOVEMENT */
  3013.            /* x= function number   t=number of times to execute  */
  3014.            val=f_value(0); p1=f_value(0);
  3015.            if(val>4) val=0;
  3016.            p2=0;
  3017.         do {
  3018.            Bconout(2,27);
  3019.            if(val==0) Bconout(2,'H');
  3020.            if(val==1) Bconout(2,'A');
  3021.            if(val==2) Bconout(2,'B');
  3022.            if(val==3) Bconout(2,'C');
  3023.            if(val==4) Bconout(2,'D');
  3024.            p2 ++;
  3025.          } while(p2<p1);
  3026.         }
  3027.  
  3028. if(key=='b') {   /*  sounds(0-19) 20=edit 21=off 22=restore */ 
  3029.              val=f_value(0); if(val>22) val=0; 
  3030.  sound_test:
  3031.   if(val<20) { 
  3032.              switch(val) {
  3033. case 0:  for(i=0;i<5*CLK_TCK;++i)
  3034.              snd_on(aa,-1,-1,-1,1); break;
  3035. case 1:  for(i=0;i<5*CLK_TCK;++i) 
  3036.              snd_on(ab,-1,-1,-1,1); break;
  3037. case 2:  for(i=0;i<5*CLK_TCK;++i)
  3038.              snd_on(ac,-1,-1,-1,1); break;
  3039. case 3:  for(i=0;i<5*CLK_TCK;++i)
  3040.              snd_on(ad,-1,-1,-1,1); break;
  3041. case 4:  for(i=0;i<5*CLK_TCK;++i)
  3042.              snd_on(ae,-1,-1,-1,1); break;
  3043. case 5:  snd_on(af,-1,-1,-1,1); break;
  3044. case 6:  snd_on(ag,-1,-1,-1,1); break;
  3045. case 7:  snd_on(ah,-1,-1,-1,1); break;
  3046. case 8:  snd_on(ai,-1,-1,-1,1); break;
  3047. case 9:  snd_on(aj,-1,-1,-1,1); break;
  3048. case 10:  snd_on(ak,-1,-1,-1,1); break;
  3049. case 11:  snd_on(al,-1,-1,-1,1); break;
  3050. case 12:  snd_on(am,-1,-1,-1,1); break;
  3051. case 13:  snd_on(an,-1,-1,-1,1); break;
  3052. case 14:  snd_on(ao,-1,-1,-1,1); break;
  3053. case 15:  snd_on(ap,-1,-1,-1,1); break;
  3054. case 16:  snd_on(aq,-1,-1,-1,1); break;
  3055. case 17:  snd_on(ar,-1,-1,-1,1); break;
  3056. case 18:  snd_on(as,-1,-1,-1,1); break;
  3057. case 19:  snd_on(landing,-1,-1,-1,1); break;
  3058.    }
  3059.  }
  3060.  if(val==20) {  /*
  3061.     b 20,play_flag,snd_num,element_num,negative_flag,thousands,ones */
  3062.     v1=f_value(0); /* play_flag */
  3063.     v2=f_value(0); /* snd_num */
  3064.     if(v2>19) v2=19;
  3065.     v3=f_value(0); /* element_num */
  3066.     if(v3>55) v3=55;
  3067.     v4=f_value(0); /* negative_flag */
  3068.     v5=f_value(0); /* thousands place */
  3069.     if(v5>32) v5=32;
  3070.     v5=v5*1000;
  3071.     v6=f_value(0); /* ones to 999s place */
  3072.     v7=v5+v6;
  3073.     if(v4) v7=0-v7;
  3074.              switch(v2) {
  3075. case 0: aa[v3]=v7; break;
  3076. case 1: ab[v3]=v7; break;
  3077. case 2: ac[v3]=v7; break; 
  3078. case 3: ad[v3]=v7; break;
  3079. case 4: ae[v3]=v7; break;
  3080. case 5: af[v3]=v7; break;
  3081. case 6: ag[v3]=v7; break;
  3082. case 7: ah[v3]=v7; break;
  3083. case 8: ai[v3]=v7; break;
  3084. case 9: aj[v3]=v7; break;
  3085. case 10: ak[v3]=v7; break;
  3086. case 11: al[v3]=v7; break;
  3087. case 12: am[v3]=v7; break;
  3088. case 13: an[v3]=v7; break;
  3089. case 14: ao[v3]=v7; break;
  3090. case 15: ap[v3]=v7; break;
  3091. case 16: aq[v3]=v7; break;
  3092. case 17: ar[v3]=v7; break;
  3093. case 18: as[v3]=v7; break;
  3094. case 19: landing[v3]=v7; break;
  3095.     }
  3096.  if(v1) { val=v2; goto sound_test; }
  3097.   }/* endif val==20 */
  3098.  
  3099. if(val==21) {  /* b 21:   STOP all sound  */
  3100. stop_snd(0); stop_snd(1); stop_snd(2);
  3101.   }
  3102. if(val==22) {  /* b 22,snd_num */
  3103.          snd_num=f_value(0);  if(snd_num>19 || snd_num<0) snd_num=0;
  3104.          for(snd_ele=0;snd_ele<56;snd_ele++) {
  3105.            switch(snd_num) {
  3106. case 0:  aa[snd_ele]=snd_patches[0][snd_ele]; break;
  3107. case 1:  ab[snd_ele]=snd_patches[1][snd_ele]; break;
  3108. case 2:  ac[snd_ele]=snd_patches[2][snd_ele]; break;
  3109. case 3:  ad[snd_ele]=snd_patches[3][snd_ele]; break;
  3110. case 4:  ae[snd_ele]=snd_patches[4][snd_ele]; break;
  3111. case 5:  af[snd_ele]=snd_patches[5][snd_ele]; break;
  3112. case 6:  ag[snd_ele]=snd_patches[6][snd_ele]; break;
  3113. case 7:  ah[snd_ele]=snd_patches[7][snd_ele]; break;
  3114. case 8:  ai[snd_ele]=snd_patches[8][snd_ele]; break;
  3115. case 9:  aj[snd_ele]=snd_patches[9][snd_ele]; break;
  3116. case 10:  ak[snd_ele]=snd_patches[10][snd_ele]; break;
  3117. case 11:  al[snd_ele]=snd_patches[11][snd_ele]; break;
  3118. case 12:  am[snd_ele]=snd_patches[12][snd_ele]; break;
  3119. case 13:  an[snd_ele]=snd_patches[13][snd_ele]; break;
  3120. case 14:  ao[snd_ele]=snd_patches[14][snd_ele]; break;
  3121. case 15:  ap[snd_ele]=snd_patches[15][snd_ele]; break;
  3122. case 16:  aq[snd_ele]=snd_patches[16][snd_ele]; break;
  3123. case 17:  ar[snd_ele]=snd_patches[17][snd_ele]; break;
  3124. case 18:  as[snd_ele]=snd_patches[18][snd_ele]; break;
  3125. case 19:  landing[snd_ele]=snd_patches[19][snd_ele]; break;
  3126.  
  3127.                         } /* end switch */
  3128.  
  3129.           } /* end for */
  3130.      } /* endif val==22 */
  3131. }
  3132.  
  3133.  
  3134. if(key=='i')  {   /* i x t  LINE INSERTS */
  3135.          /* x (0-1) 0= cursor up insert blanks if at top of screen */
  3136.          /* x (0-1) 1= insert line at cursor, bottom line is scrolled off */
  3137.          /* t = number of times to do this. */
  3138.         val=f_value(0); p1=f_value(0); 
  3139.         if(val>1) val=0;
  3140.         p2=0;
  3141.         do {
  3142.             Bconout(2,27);
  3143.             if(val==0) Bconout(2,'I');
  3144.             if(val==1) Bconout(2,'L');
  3145.             p2 ++;
  3146.             } while(p2<p1);
  3147.         }
  3148.  
  3149.  
  3150. if(key=='r')  {  /* r x  REMEMBER/RECALL cursor position */
  3151.          /* where x=0 remeber, x=1 recall */
  3152.         val=f_value(0);
  3153.         if(val>1) val=0;
  3154.         Bconout(2,27);
  3155.         if(val==0) Bconout(2,'j');
  3156.         if(val==1) Bconout(2,'k');
  3157.         }
  3158.  
  3159. if(key=='d')  {  /* d x  DELETE LINE scroll screen up a line at bottom. */
  3160.          /* x = number of lines to delete */
  3161.         val=f_value(0);
  3162.         p2=0;
  3163.         do {
  3164.             Bconout(2,27);
  3165.             Bconout(2,'M');
  3166.             p2 ++;
  3167.            } while(p2<val);
  3168.         }
  3169.  
  3170. if(key=='l')  {  /* l x  LINE CLEARS  */
  3171.          /*  x=0 clear whole line and <CR> cursor */
  3172.          /*  x=1 clear line from begining to cursor inclusive */
  3173.          /*  x=2 clear at cursor to end of line */
  3174.          val=f_value(0);
  3175.          if(val>2) val=0;
  3176.         (Bconout(2,27);
  3177.          if(val==0) Bconout(2,'l');
  3178.          if(val==1) Bconout(2,'o');
  3179.          if(val==2) Bconout(2,'K');
  3180.         }
  3181.  
  3182. if(key=='s')  {  /')  {  /')  {  /')  {  /')  {  /ad endlines */
  3183.            /*  T 2 1 60 (to 64) rounded endlines */
  3184.            /*  T 2 1 0   square endlines */
  3185.            p1=f_value(0);                     
  3186.                    if ( p1<1 || p1>2 ) break;      
  3187.                      p2=f_value(0);          
  3188.            if ( p2<1 || p2>6 ) p2=1;       
  3189.  
  3190.                    if ( p1 == 1 ) {               
  3191.              p3=f_value(0);            
  3192.            if (p3<1 || p3>8 ) p3=1;      
  3193.             vsm_type(handle,p2);         
  3194.                     vsm_height(handle,p3*11);      
  3195.             }
  3196.                    
  3197.            if (p1==2) {              
  3198.             p3=f_value(0);
  3199.             
  3200.             if (p3<42 && p3>0) {          
  3201.               if (p2>1) p3=1; 
  3202.               vsl_type(handle,p2); 
  3203.               vsl_width(handle,p3);
  3204.             }
  3205.             if (p3==0)   vsl_ends(handle,0,0);
  3206.             if (p3==50)  vsl_ends(handle,1,1);
  3207.             if (p3==51)  vsl_ends(handle,1,0);
  3208.             if (p3==52)  vsl_ends(handle,0,1);
  3209.             if (p3==53)  vsl_ends(handle,1,2);
  3210.             if (p3==54)  vsl_ends(handle,2,1);
  3211.  
  3212.             if (p3==60)  vsl_ends(handle,2,2);
  3213.             if (p3==61)  vsl_ends(handle,2,0);
  3214.             if (p3==62)  vR */
  3215.          /* f=0 set background  f=1 set text color */
  3216.          /* x  = color register */
  3217.         p1=f_value(0);  p2=f_value(0);
  3218.         if(p1>1) p1=0;
  3219.         Bconout(2,27);
  3220.         if(p1==0) { Bconout(2,'c'); Bconout(2,p2); }
  3221.         if(p1==1) { Bconout(2,'b'); Bconout(2,p2); }
  3222.         }
  3223.  
  3224. if(key=='v')  { /* v x   VIDEO (inverse on/off) */
  3225.         /* where x=0 off   x=1 on       */
  3226.         val=f_value(0);
  3227.         if(val>1) val=0;
  3228.         Bconout(2,27);
  3229.         if(val==0) Bconout(2,'q');
  3230.         if(val==1) Bconout(2,'p');
  3231.         }
  3232.  
  3233. if(key=='k')  { /* k x   CURSOR ( on/off ) and Destructive  Backspace */
  3234.         /* where x=0 off   x=1 on       */
  3235.         /* x=2 destructive backspace on, x=3 destruction off */
  3236.         val=f_value(0);
  3237.         if(val>3) val=0;
  3238.         if(val<2) Bconout(2,27);
  3239.         if(val==0) Bconout(2,'f');
  3240.         if(val==1) Bconout(2,'e');
  3241.         if(val==2) des_backsp=1;
  3242.         if(val==3) des_backsp=0;
  3243.         }
  3244.  
  3245. if(key=='w')  { /* w x   LINE WRAP ( on/off ) */
  3246.         /* where x=0 off   x=1 on       */
  3247.         val=f_value(0);
  3248.         if(val>1) val=0;
  3249.         Bconout(2,27);
  3250.         if(val==0) Bconout(2,'w');
  3251.         if(val==1) Bconout(2,'v');
  3252.         }
  3253.  
  3254.     } while(lp_flg==1 && bad_cmd !=0); /* end do  '&' command */
  3255.   }
  3256.   lp_type=' '; is_gang='X'; /* zero @ option LOOP; null gang */
  3257.  }  while ( chain == '>' );
  3258. lp_flg=0;
  3259. if(mem_key_flg) { 
  3260.                     mem_key_flg=0;
  3261.          for(v1=1;v1<mem_key_ct+1;v1++) {
  3262.              while(Bcostat(BC_AUX) == 0);
  3263.            Bconout(BC_AUX,mem_key[v1]);Bconout(BC_CON,mem_key[v1]);
  3264.          }
  3265.            if(mem_key_cr)  { Bconout(BC_AUX,13); Bconout(BC_CON,13); }
  3266.  }
  3267.  
  3268. }
  3269. /*************/
  3270. play_note(p1,p2,p3,p4,p5,p6)
  3271. int p1,p2,p3,p4,p5,p6;
  3272. {
  3273. int ext;
  3274. unsigned long timer1,timer2;
  3275.                 /* Musical Note Routine has 6 parameters p1-p6 */
  3276.                 /* 1 = effect number(0-19)    2 = voice number(0-2) */
  3277.                 /* 3 = volume(0-15)           4 = pitch(0-255)  */
  3278.                 /* 5 = pause in 200ths sec (0-9999) */
  3279.                 /* 6 = stop sound type (0-4)   */
  3280.         if(p1<0) p1=0;
  3281.         if(p2>2) p2=2;
  3282.         if(p2<0) p2=0;
  3283.         if(p1>19 && p1!=125) p1=19;
  3284.         if(p3>15) p3=15;
  3285.         if(p3<0) p3=0;
  3286.         if(p4>255) p4=255;
  3287.         if(p5<0) p5=0;
  3288.         if(p6>4) p6=4;
  3289.         if(p6<0) p6=0;
  3290. if(p4>0) {
  3291.              switch(p1) {
  3292. case 0: snd_on(aa,p2,p3,p4,7); break;
  3293. case 1: snd_on(ab,p2,p3,p4,7); break;
  3294. case 2: snd_on(ac,p2,p3,p4,7); break;
  3295. case 3: snd_on(ad,p2,p3,p4,7); break;
  3296. case 4: snd_on(ae,p2,p3,p4,7); break;
  3297. case 5: snd_on(af,p2,p3,p4,7); break;
  3298. case 6: snd_on(ag,p2,p3,p4,7); break;
  3299. case 7: snd_on(ah,p2,p3,p4,7); break;
  3300. case 8: snd_on(ai,p2,p3,p4,7); break;
  3301. case 9: snd_on(aj,p2,p3,p4,7); break;
  3302. case 10: snd_on(ak,p2,p3,p4,7); break;
  3303. case 11: snd_on(al,p2,p3,p4,7); break;
  3304. case 12: snd_on(am,p2,p3,p4,7); break;
  3305. case 13: snd_on(an,p2,p3,p4,7); break;
  3306. case 14: snd_on(ao,p2,p3,p4,7); break;
  3307. case 15: snd_on(ap,p2,p3,p4,7); break;
  3308. case 16: snd_on(aq,p2,p3,p4,7); break;
  3309. case 17: snd_on(ar,p2,p3,p4,7); break;
  3310. case 18: snd_on(as,p2,p3,p4,7); break;
  3311. case 19: snd_on(landing,p2,p3,p4,7); break;
  3312.    }
  3313.  }
  3314.  
  3315. ext=0;
  3316. if(p5==0) ext=1;
  3317. timer1 = clock1();
  3318. while (ext==0) {
  3319.         timer2 = clock1();
  3320.             if(Bconstat(BC_CON)) {
  3321.                 Bconin(BC_CON);
  3322.                 ext=1;
  3323.               }
  3324.  
  3325.         if ( (timer2-timer1) >= p5 ) {
  3326.                  ext=1;
  3327.            }
  3328.     } /* end while ext==0 */
  3329.   if(p6>0) {
  3330.         if(p6==1) snd_off(p2);
  3331.         if(p6==2) stop_snd(p2);
  3332.         if(p6==3) { snd_off(0); snd_off(1); snd_off(2); }
  3333.         if(p6==4) { stop_snd(0); stop_snd(1); stop_snd(2); }
  3334.    }
  3335.  
  3336.  
  3337. /*************/
  3338. get_char() {
  3339.  
  3340. unsigned char kar;
  3341.  
  3342. kar=0;
  3343.  
  3344. f_ct ++;
  3345. bytes_parsed ++;
  3346.  
  3347. if (f_ct>=bytes_read && bytes_left>0 ) { 
  3348.     read_file();
  3349.     f_ct=0;
  3350.     if (bytes_read>0) kar=filebuffer[f_ct];    
  3351.     }
  3352.  
  3353. if (f_ct<bytes_read) kar=filebuffer[f_ct];
  3354.  
  3355. return(kar);  
  3356. }
  3357. /*************/
  3358. f_get_text() {
  3359.  
  3360. /* get a string up to 128 characters from disk buffer @ ends string */
  3361.  
  3362. int  key, ct, recieving, fl_at;
  3363.  
  3364. ct=0; fl_at=0;
  3365. recieving=1;
  3366. if(lp_flg==1 && lp_type !='@') recieving=0;
  3367. if(lp_flg==0 && lp_type=='Z') { recieving=0; lp_type=' '; }
  3368. while (recieving) {
  3369.  
  3370.         key = get_char();
  3371.         
  3372.         if ( key==0 ) recieving=0;
  3373.  
  3374.             if (key>0) {
  3375.         if ( ct<128 && key != '@' && key!=10 && key!=13) {    
  3376.         text[ct] = key;
  3377.             ct++;
  3378.          }
  3379.         if ( ct==128 || key=='@' ) {
  3380.             if(ct==0) { text[ct]='@'; ct++; }
  3381.               text[ct]=0;
  3382.               recieving=0;
  3383.             }
  3384.              }
  3385.  
  3386.            }
  3387. bad_cmd=1;
  3388. }
  3389. /**********/
  3390. f_value(x_y) 
  3391. int x_y;
  3392. {
  3393. float scale_ratio,round;
  3394. int num,v1,v2,v3,v4,ct,flg,key,x_screen,y_screen, plus_minus_flg;
  3395. unsigned long t1, t2;
  3396.     num=0; v1=0, v2=0, v3=0, v4=0, ct=0, flg=0, plus_minus_flg=0;
  3397.  
  3398. if(lp_flg==0) {
  3399. f_v_jmp:
  3400. do {
  3401. key = get_char();
  3402.  
  3403. if (key<48 || key>57)  flg=1;
  3404.    else  {
  3405.     ct++;
  3406.     switch(ct) {
  3407.         case 1:  v1=key-48;
  3408.             break;
  3409.         case 2:  v2=key-48;
  3410.             break;
  3411.         case 3:  v3=key-48;
  3412.             break;
  3413.         case 4:  v4=key-48;
  3414.             break;
  3415.         default:  num=0;
  3416.         
  3417.         }
  3418.        } 
  3419. }  while ( flg == 0 );
  3420.  
  3421. switch(ct) {
  3422.     case 4: v3*=10; v2*=100; v1*=1000; num=v4+v3+v2+v1;
  3423.         break;
  3424.     case 3: v2*=10; v1*=100; num=v3+v2+v1;
  3425.         break;
  3426.     case 2: v1*=10; num=v2+v1;
  3427.         break;
  3428.     case 1: num=v1;
  3429.         break;
  3430.     default: num=0;
  3431.         
  3432.       }
  3433. if(g_s && x_y>0 && num>0) { /* If scaling set and desired do it! */
  3434.   if(g_s!=2) {
  3435.     if((g_res==2 || g_res==1) && x_y==1) x_screen=639;
  3436.     if(g_res==2 && x_y==2) y_screen=399;
  3437.     if((g_res==1 || g_res==0) && x_y==2) y_screen=199;
  3438.     if(g_res==0 && x_y==1) x_screen=319;
  3439.     scale_ratio=9999/num; 
  3440.     if(x_y==1) round=x_screen/scale_ratio;
  3441.     if(x_y==2) round=y_screen/scale_ratio;
  3442.     if(round-(int)round> .49) num=(int)round+1;
  3443.     if(round-(int)round< .5) num=(int)round;
  3444.    }
  3445.      /*  g 2: option */
  3446.      if(g_s==2 && x_y==2 && g_res==2) num*=2;
  3447.  
  3448.     }
  3449. if(key=='_') { key=get_char(); key=get_char(); flg=0; goto f_v_jmp; }
  3450. if(key==120) { num= -32767; key=get_char(); }
  3451. if(key==121) { num= -32766; key=get_char(); }
  3452. if(key=='r') { num= -32765; key=get_char(); }
  3453. /****  ,+CONSTANT,-CONSTANT, !CONSTANT ****/
  3454. if(key=='+') { plus_minus_flg=1; flg=0; goto f_v_jmp; }
  3455. if(key=='-') { plus_minus_flg=2; flg=0; goto f_v_jmp; }
  3456. if(key=='!') { plus_minus_flg=3; flg=0; goto f_v_jmp; }
  3457. if(plus_minus_flg==1) num= 0-num;
  3458. if(plus_minus_flg==2) num= 0-10000-num;
  3459. if(plus_minus_flg==3) num= 0-20000-num;
  3460.   } /* endif lp_flg */
  3461. if(lp_flg==1) { if (lp_eff_ct==0) lp_x=0;
  3462.  
  3463.                         if(lp_eff_ct==0) {
  3464.                          t1=clock1();
  3465.                          do {
  3466.                             t2=clock1();
  3467.                             if(Bconstat(BC_CON)) break;
  3468.                             } while (t2-t1<lp4);
  3469.                           }
  3470.  
  3471.  
  3472. if(lp_effect[lp_eff_ct] != -32767 && lp_effect[lp_eff_ct] != -32766) num=lp_effect[lp_eff_ct];
  3473. if(lp_effect[lp_eff_ct] == -32767 || lp_effect[lp_eff_ct] == -32766 || (lp_effect[lp_eff_ct]> -30000 && lp_effect[lp_eff_ct]<0))
  3474.                      {
  3475.                         lp_x++;
  3476.                         if(lp_2nd==0) lp_was=lp1;
  3477.                         if(lp_x<2 && lp_1st!=0) { lp1+=lp3; lp_2nd++;  
  3478.                         if(lp_2nd==1 && lp_type=='|') lp1=lp_was;
  3479.                         if(lp_2nd==2 && lp_type=='|') lp_2nd=0;
  3480.                          }
  3481.                          if(lp_effect[lp_eff_ct]< -29999) num=lp1;
  3482.                         lp_1st++;
  3483.                         if(lp_effect[lp_eff_ct]== -32766) {
  3484.                             if(lp5<lp2) num=lp2-lp1;
  3485.                             if(lp5>lp2) num=lp5-lp1;
  3486.                             if(lp5==lp2) num=0;
  3487.                         }
  3488.                         /* +CONSTANT */
  3489.                       if(num<0 && num> -10000) num=abs(num)+lp1;
  3490.                         /* -CONSTANT */
  3491.                       if(num< -9999 && num> -20000) {
  3492.                        num+=10000;
  3493.                        num=abs(num);
  3494.                        num=lp1-num;
  3495.                       }
  3496.                         /* !CONSTANT */
  3497.                       if(num< -19999 && num> -30000) {
  3498.                        num+=20000;
  3499.                        num=abs(num);
  3500.                        num-=lp1;
  3501.                       }
  3502.  
  3503.                     }
  3504.  
  3505.         /* Check for CTRL-C from user to abort LOOP */
  3506.                 if (Bconstat(BC_CON)) {
  3507.                 key = Bconin(BC_CON);
  3508.                 if (key == 3 || key==24) lp_flg=0;
  3509.              }
  3510.  
  3511.                 if(lp_no_prams==1 && lp_eff_ct==0) lp1+=lp3;
  3512.                 if(lp3>=1 && lp1>=lp2 && lp_eff_ct==(lp_num_prams-1)) lp_flg=0;
  3513.                 if(lp3<0 && lp1<=lp2 && lp_eff_ct==(lp_num_prams-1)) lp_flg=0; 
  3514.                 if(lp_type!='@' && lp_flg==0 && lp_com=='W') lp_type='Z';
  3515.  
  3516.                 lp_eff_ct++; 
  3517.                 if(lp_eff_ct>=lp_num_prams)  lp_eff_ct=0;
  3518.  
  3519.                 }
  3520. if(num== -32765 && r_lp==0) num=r_random();
  3521. bad_cmd=1;
  3522. return(num);
  3523.  }
  3524.  
  3525. /*********************/
  3526. reset_attributes()  {
  3527. int d1, d2,d3,d4;
  3528.  
  3529. /** Sets attributes that were active at time program was ran **/
  3530. vsm_type(handle,polym_sets[0]);
  3531. vsm_color(handle,polym_sets[1]);
  3532. vswr_mode(handle,polym_sets[2]);
  3533. vsm_height(handle,polym_sets[3]);
  3534. /*** end of polymarker restore ****/
  3535.  
  3536. vsl_type(handle,line_sets[0]);
  3537. vsl_color(handle,line_sets[1]);
  3538. vsl_width(handle,line_sets[3]);
  3539. vsl_ends(handle,line_sets[4],line_sets[5]);
  3540. /*** end line set restore ***/
  3541.  
  3542. vsf_interior(handle,fill_sets[0]);
  3543. vsf_color(handle,fill_sets[1]);
  3544. vsf_style(handle,fill_sets[2]);
  3545. /*** end fill restore ***/
  3546.  
  3547. vst_color(handle,text_sets[1]);
  3548. vst_rotation(handle,text_sets[2]);
  3549. vst_effects(handle,0);
  3550. vst_height(handle,text_sets[7],&d1,&d2,&d3,&d4);
  3551.  
  3552. }
  3553. /*****************/
  3554. help_display() {
  3555. Cconws("\33E\33p                               Instant Graphics!                                ");
  3556. Cconws("\n\r\33q   Copyright 1988-92   by Larry Mears, all rights reserved.   v2.17 Shareware");
  3557. Cconws("\n\r     *--------------------------------------------------------------------*");
  3558. Cconws("\n\r     |Send $15 appreciation fee to:                                       |");
  3559. Cconws("\n\r     | Larry Mears  11027 Crestfield Dr.   Huntsville, Alabama  35803 USA |");
  3560. Cconws("\n\r     |IG Emulator Support: BIG City  WWIVNET Node 2509 205-880-9896       |");           
  3561. Cconws("\n\r     |--------------------------------------------------------------------|");
  3562. Cconws("\n\r     |IG XNET     Support: London Smog       Node 632  714-546-2152       |");
  3563. Cconws("\n\r     |IG UK       Support: Internet          Node 1031 +44-296-395935     |");
  3564. Cconws("\n\r     |....................................................................|");
  3565. Cconws("\n\r     | Help      This display           | F5      Resolution Lock toggle  |");
  3566. Cconws("\n\r     | Undo      Exit program           | F6      Duplex toggle           |");
  3567. Cconws("\n\r     | ClrHome   Reset color,attributes | F7      Display a file          |");
  3568. Cconws("\n\r     | Insert    Set Baud rate          | F8      Execute file graphics   |");
  3569. Cconws("\n\r     | +         MIDI  Sync adjust      | F9      Activate graphics       |");
  3570. Cconws("\n\r     | F4        MIDI  on / off         | F10     Deactivate graphics     |");
  3571. Cconws("\n\r     *--------------------------------------------------------------------*\n\n\r\33e");
  3572. }
  3573.  
  3574. clock1()
  3575. {
  3576.   unsigned long User_stack = Super(0L);
  3577.   unsigned long ticks = *(unsigned long *)0x4ba;
  3578.  
  3579.   Super(User_stack);
  3580.   return ticks;
  3581. }
  3582.  
  3583. get_aux_char() {
  3584.  
  3585. int ext, c_aux;
  3586. unsigned long timer1,timer2;
  3587.  
  3588. ext=0;
  3589. timer1 = clock1();
  3590. while (ext==0) {
  3591.         timer2 = clock1();
  3592.             if (Bconstat(BC_AUX)) {
  3593.                 c_aux = Bconin(BC_AUX);
  3594.                 ext=1;
  3595.              }
  3596.  
  3597.     /* time out in 5 seconds */
  3598.     if ( ((timer2/CLK_TCK)-(timer1/CLK_TCK)) > 4 ) {
  3599.             c_aux=' ';
  3600.         Bconout(BC_CON,7); ext=1;
  3601.            }
  3602.  
  3603.     } /* end while ext==0 */
  3604. return(c_aux);
  3605. }
  3606.  
  3607.  
  3608. r_random()
  3609. {
  3610. unsigned long rd;
  3611. int rx;
  3612.  
  3613.     do {
  3614.         rd=Random();
  3615.         rx=(int)rd;
  3616.         if(rnd_t<256) rx=(unsigned char)rd;
  3617.     } while(rx<rnd_f || rx>rnd_t);
  3618.  
  3619. return(rx);
  3620. }
  3621.  
  3622. xoff() {
  3623. int x_i;
  3624.   
  3625.     if(x_on) {
  3626.         for(x_i=0;x_i<x_times_x;times_x;times_x;times_x;times_x;F4        MIDI  on / off         | F10     Deactivate graphics     |");
  3627. Cconws("\n\r     *--------------------------------------------------------------------*\n\n\r\33e");
  3628. }
  3629.  
  3630. clock1()
  3631. {
  3632.   unsigned long User_stack = Super(0L);
  3633.   unsigned long ticks = *(unsigned long *)0x4ba;
  3634.  
  3635.   Super(User_stack);
  3636.   return ticks;
  3637. }
  3638.  
  3639. get_aux_char() {
  3640.  
  3641. int ext, c_aux;
  3642. unsigned long timer1,timer2;
  3643.  
  3644. ext=0;
  3645. timer1 = clock1();
  3646. while (ext==0) {
  3647.         timer2 = clock1();
  3648.           ("\n\r                           Press HELP for options list.\n\n\r\33e");
  3649. }
  3650.  
  3651.  
  3652. /****  pause for X number of 200s of a sec ****/
  3653. delay(X200s) 
  3654. int X200s;
  3655. {
  3656.  
  3657. unsigned long timer1, timer2;
  3658.            timer1 = clock1();
  3659.  
  3660.            do {
  3661.             timer2 = clock1();
  3662.  
  3663.             if(Bconstat(BC_CON)) {
  3664.                 /* Bconin(BC_CON); */
  3665.                 X200s=0;
  3666.               }
  3667.  
  3668.                   } while ( (timer2-timer1) < X200s );    
  3669.  
  3670. }
  3671.  /* ************************************************************** */
  3672.  /* *             VDI compatible resolution change               * */
  3673.  /* *                      courtesy of                           * */
  3674.  /* *    Steve Cole/Kinbinki Boy  &  Lawrence Gold/King Midas    * */
  3675.  /* ************************************************************** */
  3676.  
  3677.  /* Obviously the function to change to low resolution */
  3678. rez_change_low()
  3679. {
  3680.      asm {
  3681.           movem.l  D0/A0-A2,-(A7)
  3682.           dc.w     0xA000
  3683.           move.w   #319,-692(A0)
  3684.           move.w   #199,-690(A0)
  3685.           move.w   #16,-666(A0)
  3686.           move.w   #338,-686(A0)
  3687.           move.w   #0,-(A7)
  3688.           move.l   #-1,-(A7)
  3689.           move.l   #-1,-(A7)
  3690.           move.w   #5,-(A7)
  3691.           trap     #14
  3692.           lea.l    12(A7),A7
  3693.           movem.l  (A7)+,D0/A0-A2
  3694.      }
  3695.     Bconout(2,27); Bconout(2,'v');
  3696. }
  3697.  
  3698.  /* The function to change to medium resolution */
  3699. rez_change_med()
  3700. {
  3701.      asm {
  3702.           movem.l  D0/A0-A2,-(A7)
  3703.           dc.w     0xA000  
  3704.           move.w   #639,-692(A0)
  3705.           move.w   #199,-690(A0)
  3706.           move.w   #4,-666(A0)
  3707.           move.w   #169,-686(A0)
  3708.           move.w   #1,-(A7)
  3709.           move.l   #-1,-(A7)
  3710.           move.l   #-1,-(A7)
  3711.           move.w   #5,-(A7)
  3712.           trap     #14
  3713.           lea.l    12(A7),A7
  3714.           movem.l  (A7)+,D0/A0-A2
  3715.      }
  3716.     Bconout(2,27); Bconout(2,'v');
  3717. }
  3718.  
  3719. /* The fix for Flash */
  3720. flash_fix() 
  3721. {
  3722.      asm{
  3723.           movem.l  D0/A0-A2,-(A7)
  3724.           dc.w     0xA000
  3725.           move.w   #23,-42(A0)
  3726.           lea.l    12(A7),A7
  3727.           movem.l  (A7)+,D0/A0-A2
  3728.      }
  3729. }
  3730.