home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / SGTOOL13.ARC / DEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-28  |  15.3 KB  |  637 lines

  1. /*
  2. SG C Tools 1.3
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. SG C Tools Demo shows how to use some of the features available with SG C
  8. Tools.
  9.  
  10. Compiled with HI-TECH C 3.09 (CP/M-80).
  11.  
  12. To compile with HI-TECH C and SG C Tools source on same disk use:
  13. C DEMO.C -LC128
  14. */
  15.  
  16. #include <ctype.h>
  17. #include <conio.h>
  18. #include <sys.h>
  19. #include <hitech.h>
  20. #include <vdc.h>
  21. #include <cia.h>
  22. #include <sid.h>
  23.  
  24. /* 64k vdc locations */
  25.  
  26. #define appBitMapMem 0x4000
  27. #define appAttrMem   0x8000
  28.  
  29. /* colors used by this app */
  30.  
  31. #define appClockCo     vdcAltChrSet+vdcRvsVid+vdcLightPurple
  32. #define appMenuScrCo   vdcDarkBlue
  33. #define appDeskCo      vdcAltChrSet+vdcMediumGray
  34. #define appMenuTxtCo   vdcAltChrSet+vdcLightCyan
  35. #define appMenuWinCo   vdcAltChrSet+vdcLightBlue
  36. #define appIScrCo      vdcBlack
  37. #define appIDeskCo     vdcAltChrSet+vdcMediumGray
  38. #define appIWinTxtCo   vdcAltChrSet+vdcDarkBlue
  39. #define appIWinCo      vdcAltChrSet+vdcDarkYellow
  40. #define appGrTextCo    (vdcDarkGray << 4) | vdcWhite
  41. #define appSoundWinCo  vdcAltChrSet+vdcWhite
  42. #define appSoundTxt1Co vdcAltChrSet+vdcLightGreen+vdcBlink
  43. #define appSoundTxt2Co vdcAltChrSet
  44. #define appCtrlTxt1Co  vdcAltChrSet+vdcRvsVid+vdcLightYellow
  45. #define appCtrlTxt2Co  vdcAltChrSet+vdcWhite
  46. #define appCtrlWinCo   vdcAltChrSet+vdcLightCyan
  47.  
  48. extern uchar     vdcScrHorz;
  49. extern ushort    vdcDispMem;
  50. extern ushort    vdcAttrMem;
  51. extern ushort    vdcCharMem;
  52. extern ushort    vdcCharMemSize;
  53. extern uchar     sidPot1X;
  54. extern uchar     sidPot1Y;
  55. extern uchar     sidPot2X;
  56. extern uchar     sidPot2Y;
  57. extern uchar     sidMouse1X;
  58. extern uchar     sidMouse1Y;
  59. extern uchar     sidMouse2X;
  60. extern uchar     sidMouse2Y;
  61. extern uchar     ciaJoy1;
  62. extern uchar     ciaJoy2;
  63. extern ciaKeyRec ciaKeyScan;
  64.  
  65. void initbitmap64k(void);
  66. void initbitmap16k(void);
  67. uchar savechrsets(void);
  68. void restorechrsets(void);
  69. void draw16khelp(uchar Rect[]);
  70. void drawmenu(uchar Rect[]);
  71. void colordisp(void);
  72. void graphicsview(void);
  73. void set64kmode(void);
  74. void ilace80x50text(void);
  75. void drawlines(void);
  76. void drawtext(void);
  77. void drawcircles(void);
  78. void drawrect(int Rect[]);
  79. void drawhouse(void);
  80. void drawcolors(void);
  81.  
  82. void delay(ushort D);
  83. void planesound(void);
  84. void shotssound(void);
  85. void explodesound(void);
  86. void bombdropsound(void);
  87. void soundseq(uchar Rect[], uchar Seq);
  88. void soundwin(uchar Rect[]);
  89.  
  90. void controlswin(uchar Rect[]);
  91. void dispclock(void);
  92.  
  93. void init(void);
  94. void run(void);
  95. void done(void);
  96.  
  97. uchar *appChSetBufPtr; /* char set buffer pointer */
  98. uchar appColors[] =    /* colors for 64k graphics */
  99. {
  100. vdcDarkGray,
  101. vdcDarkBlue,
  102. vdcLightBlue,
  103. vdcLightBlue,
  104. vdcDarkCyan,
  105. vdcDarkCyan,
  106. vdcDarkCyan,
  107. vdcLightCyan,
  108. vdcLightCyan,
  109. vdcLightCyan,
  110. vdcMediumGray,
  111. vdcMediumGray,
  112. vdcWhite,
  113. vdcMediumGray,
  114. vdcMediumGray,
  115. vdcLightCyan,
  116. vdcLightCyan,
  117. vdcLightCyan,
  118. vdcDarkCyan,
  119. vdcDarkCyan,
  120. vdcDarkCyan,
  121. vdcLightBlue,
  122. vdcLightBlue,
  123. vdcDarkBlue,
  124. vdcDarkGray
  125. };
  126.  
  127. char *appMenuItems[6] =            /* text used by this app */
  128. {
  129. "[A] SID sound effects",
  130. "[B] Keyboard, joy stick, paddle and mouse controls",
  131. "[C] 80 X 50 interlaced text",
  132. "[D] 640 X 200 lines",
  133. "[E] 640 X 200 circles",
  134. "[F] 640 X 200 houses",
  135. };
  136.  
  137. char *app16KHelp[5] =
  138. {
  139. "DO NOT select [S] option",
  140. "if your C128 has a 16K VDC!",
  141. "If you have a 64K VDC use",
  142. "[S] to get color and text",
  143. "in graphics mode!"
  144. };
  145.  
  146. char *appSoundSeq[4] =
  147. {
  148. "Plane",
  149. "Shots",
  150. "Bomb dropping",
  151. "Explosion"
  152. };
  153.  
  154. uchar appMenuRect[]  = {10,2,69,12};   /* menu window location */
  155. uchar app16KRect[]   = {24,15,56,22};  /* 16k help window location */
  156. uchar appSoundRect[] = {19,7,59,17};   /* sound window location */
  157. uchar appControlRect[] = {10,2,69,14}; /* control window location */
  158.  
  159. ciaTODRec appTOD = {0,0,0,0};          /* used to set tod clock to 12 am */
  160.  
  161. main()
  162. {
  163.   init();
  164.   run();
  165.   done();
  166. }
  167.  
  168. void initbitmap64k(void)
  169. {
  170.   setcursorvdc(0,0,vdcCurNone);    /* turn cursor off */
  171.   outvdc(vdcFgBgColor,vdcBlack);   /* black screen */
  172.   attrsoffvdc();                   /* disable attrs */
  173.   setbitmapvdc(appBitMapMem,appAttrMem,vdcBlack,vdcBlack); /* black fg bg */
  174.   mapvdc();                        /* set global vdc vars to reflect changes */
  175.   clrattrvdc(vdcBlack);
  176.   clrbitmapvdc(0);                 /* clear bit map */
  177.   attrsonvdc();                    /* enable attrs */
  178. }
  179.  
  180. void initbitmap16k(void)
  181. {
  182.   setcursorvdc(0,0,vdcCurNone);    /* turn cursor off */
  183.   outvdc(vdcFgBgColor,vdcBlack);   /* black screen */
  184.   attrsoffvdc();                   /* disable attrs to work on 16k vdc */
  185.   setbitmapvdc(vdcDispMem,vdcAttrMem,vdcWhite,vdcBlack);
  186.   clrbitmapvdc(0);                 /* clear bit map */
  187. }
  188.  
  189. uchar savechrsets(void)
  190. {
  191.   if(is64kvdc())
  192.     return(1);
  193.   else
  194.   {
  195.     appChSetBufPtr = memtobufvdc(vdcCharMem,vdcCharMemSize);
  196.     if (appChSetBufPtr != NULL)
  197.       return(1);
  198.     else
  199.       return(0);
  200.   }
  201. }
  202.  
  203. void restorechrsets(void)
  204. {
  205.   if(appChSetBufPtr != NULL)
  206.   {
  207.     outvdc(vdcFgBgColor,vdcBlack); /* set foreground-background to black */
  208.     attrsoffvdc();                 /* disable attrs */
  209.     buftomemvdc(appChSetBufPtr,vdcCharMem,vdcCharMemSize);
  210.   }
  211. }
  212.  
  213. void draw16khelp(uchar Rect[])
  214. {
  215.   uchar I;
  216.  
  217.   winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appMenuWinCo,"VDC Help");
  218.   for(I=0; I < 5; I++)
  219.     printstrvdc(Rect[0]+2,Rect[1]+I+2,appMenuTxtCo,app16KHelp[I]);
  220. }
  221.  
  222. void drawmenu(uchar Rect[])
  223. {
  224.   uchar I;
  225.  
  226.   outvdc(vdcFgBgColor,appMenuScrCo); /* set new screen color */
  227.   setcursorvdc(0,0,vdcCurNone);      /* turn cursor off */
  228.   clrattrvdc(appDeskCo);             /* draw desk top */
  229.   clrscrvdc(137);
  230.   printstrvdc(47,0,appClockCo," CP/M               RUN          ");
  231.   winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appMenuWinCo,"SG C Tools 1.3 Demo (C) 1993");
  232.   for(I=0; I < 6; I++)
  233.     printstrvdc(Rect[0]+2,Rect[1]+I+2,appMenuTxtCo,appMenuItems[I]);
  234.   if(is64kvdc())
  235.     printstrvdc(Rect[0]+2,Rect[1]+8,appMenuTxtCo,"[G] 640 X 200 color chart");
  236.   else
  237.   {
  238.     printstrvdc(Rect[0]+2,Rect[3]-2,appMenuTxtCo,"[S] Set 64K mode");
  239.     draw16khelp(app16KRect);
  240.   }
  241.   printstrvdc(Rect[0]+2,Rect[3]-1,appMenuTxtCo,"[X] Exit to CP/M");
  242. }
  243.  
  244. void colordisp(void) /* colors for 64k graphics */
  245. {
  246.   uchar I;
  247.  
  248.   for(I = 0; I <= sizeof(appColors); I++)
  249.     fillattrvdc(0,I,vdcScrHorz,appColors[I]);
  250. }
  251.  
  252. void graphicsview(void) /* view graphics until key pressed */
  253. {
  254.   while (!(kbhit()));
  255.   getch();
  256.   outvdc(vdcFgBgColor,vdcBlack);
  257.   attrsoffvdc();
  258.   restorechrsets();
  259.   restorevdc();
  260.   mapvdc();
  261.   drawmenu(appMenuRect);
  262. }
  263.  
  264. void set64kmode(void)
  265. {
  266.   if(!(is64kvdc()) && appChSetBufPtr != NULL)
  267.   {
  268.     restorevdc();         /* make sure all registers are default value */
  269.     set64kvdc();          /* set 64k mode */
  270.     savevdc();            /* reflect change to reg 28 */
  271.     restorechrsets();     /* restore char sets destroyed by setting 64k mode */
  272.     free(appChSetBufPtr); /* dispose buffer */
  273.     appChSetBufPtr = NULL;
  274.     restorevdc();
  275.     mapvdc();
  276.     drawmenu(appMenuRect);
  277.   }
  278. }
  279.  
  280. void ilace80x50text(void)
  281. {
  282.   uchar I;
  283.  
  284.   outvdc(vdcFgBgColor,appIScrCo); /* set new screen color */
  285.   setdsppagevdc(vdcDispMem,vdcAttrMem << 1);
  286.   set80x50textvdc();
  287.   mapvdc();                       /* map changes */
  288.   clrattrvdc(appIDeskCo);
  289.   clrscrvdc(137);
  290.   winvdc(10,5,69,44,appIWinCo,"Interlace 80 X 50 Mode");
  291.   printstrvdc(11,43,appIWinTxtCo,
  292.   "All functions that operate in 80 X 25 work in 80 X 50 too!");
  293.   for (I = 1; I <= 36; I++)       /* scroll window */
  294.     scrollupvdc(11,7,68,43);
  295.   while (!(kbhit()));
  296.   getch();
  297.   clrattrvdc(vdcAltChrSet);
  298.   clrscrvdc(32);
  299.   restorevdc();
  300.   mapvdc();
  301.   drawmenu(appMenuRect);
  302. }
  303.  
  304. void drawlines(void)
  305. {
  306.   int I;
  307.  
  308.   if(is64kvdc())
  309.   {
  310.     initbitmap64k();
  311.     colordisp();
  312.   }
  313.   else
  314.     initbitmap16k();
  315.   for(I = 0; I <= 639; I += 40)
  316.   {
  317.     linevdc(319,0,I,199);
  318.     linevdc(I,0,319,199);
  319.   }
  320.   if(is64kvdc())
  321.     printbmvdc(12,1,appGrTextCo,
  322.     "SG C Tools makes it easy to use text in GRAPHICS mode!");
  323.   graphicsview();
  324. }
  325.  
  326. void drawcircles(void)
  327. {
  328.   int I;
  329.  
  330.   if(is64kvdc())
  331.   {
  332.     initbitmap64k();
  333.     colordisp();
  334.     printbmvdc(27,11,appGrTextCo,"Graphics merge with text!");
  335.   }
  336.   else
  337.     initbitmap16k();
  338.   for(I = 0; I <= 199; I += 32)
  339.   {
  340.     circlevdc(319,99,I);
  341.   }
  342.   if(is64kvdc())
  343.     printbmvdc(28,13,appGrTextCo,"Text overlays graphics!");
  344.   graphicsview();
  345. }
  346.  
  347. void drawrect(int Rect[])
  348. {
  349.   linevdc(Rect[0],Rect[1],Rect[2],Rect[1]);
  350.   linevdc(Rect[0],Rect[3],Rect[2],Rect[3]);
  351.   linevdc(Rect[0],Rect[1],Rect[0],Rect[3]);
  352.   linevdc(Rect[2],Rect[1],Rect[2],Rect[3]);
  353. }
  354.  
  355. void drawhouse(void)
  356. {
  357.   int DX, DY, X, Y, HseRect[4];
  358.  
  359.   if(is64kvdc())
  360.   {
  361.     initbitmap64k();
  362.     colordisp();
  363.     printbmvdc(28,1,appGrTextCo," Houses under the moon ");
  364.   }
  365.   else
  366.     initbitmap16k();
  367.   for(Y = 0; Y < 2; Y++)
  368.     for(X = 0; X < 5; X++)
  369.     {
  370.       HseRect[0] = X*70+50;
  371.       HseRect[2] = HseRect[0]+30;
  372.       HseRect[1] = Y*50+70;
  373.       HseRect[3] = HseRect[1]+10;
  374.       DX = HseRect[2]-HseRect[0];
  375.       DY = HseRect[3]-HseRect[1];
  376.       drawrect(HseRect);
  377.       linevdc(HseRect[0],HseRect[1],HseRect[0]+(DX >> 1),HseRect[1]-DY);
  378.       linevdc(HseRect[2],HseRect[1],HseRect[0]+(DX >> 1),HseRect[1]-DY);
  379.       linevdc(HseRect[0],HseRect[3],HseRect[0]-DX,HseRect[3]-DY);
  380.       linevdc(HseRect[0]-DX,HseRect[3]-DY,HseRect[0]-DX,HseRect[3]-(DY << 1));
  381.       linevdc(HseRect[0],HseRect[1],HseRect[0]-DX,HseRect[1]-DY);
  382.       linevdc(HseRect[0]-DX,HseRect[1]-DY,HseRect[0]-(DX >> 1),HseRect[1]-(DY << 1));
  383.       linevdc(HseRect[0]+(DX >> 1),HseRect[1]-DY,HseRect[0]-(DX >> 1),HseRect[1]-(DY << 1));
  384.     }
  385.   for(X = 0; X <= 30; X++)
  386.   {
  387.     circlevdc(500,50,X);
  388.   }
  389.   graphicsview();
  390. }
  391.  
  392. void drawcolors(void)
  393. {
  394.   uchar X, Y;
  395.  
  396.   if(is64kvdc())
  397.   {
  398.     initbitmap64k();
  399.     clrattrvdc(vdcBlack);
  400.     printbmvdc(32,2,appGrTextCo,"Bit map colors");
  401.     for (Y = 0; Y < 16; Y++)
  402.       for (X = 0; X < 16; X++)
  403.         printbmvdc(X+31,Y+4,(Y << 4) | X,"*");
  404.     graphicsview();
  405.   }
  406. }
  407.  
  408. void delay(ushort D) /* delay in milliseconds (1/1000 sec) */
  409. {
  410.   setintctrlcia(cia2,ciaClearIcr); /* disable all cia 2 interrupts */
  411.   settimerbcia(cia2,D,ciaCountA);  /* timer b counts timer a underflows */
  412.   settimeracia(cia2,timervalcia(1000),ciaCPUCont); /* set timer a 1/1000 sec */
  413.   while ((inp(cia2+ciaIntCtrl) & 0x02) == 0);      /* wait for count down */
  414. }
  415.  
  416. void planesound(void)
  417. {
  418.   ushort Pulse;
  419.   ushort Freq = 2047;
  420.  
  421.   volumesid(15,0);
  422.   envelopesid(sidVoice1,12,10,0,0);
  423.   attacksid(sidVoice1,sidWaveSqu);
  424.   for(Pulse = 0; Pulse < 3840; Pulse += 10)
  425.   {
  426.     pulsewavesid(sidVoice1,Pulse);
  427.     freqsid(sidVoice1,Freq);
  428.     Freq -= 5;
  429.     delay(2);
  430.   }
  431.   releasesid(sidVoice1,sidWaveSqu);
  432.   delay(6);
  433.   freqsid(sidVoice1,0);
  434. }
  435.  
  436. void shotssound(void)
  437. {
  438.   uchar I;
  439.  
  440.   volumesid(15,0);
  441.   for(I = 0; I < 20; I++)
  442.   {
  443.     envelopesid(sidVoice1,0,3,0,0);
  444.     freqsid(sidVoice1,5360);
  445.     attacksid(sidVoice1,sidWaveNoi);
  446.     delay(100);
  447.     releasesid(sidVoice1,sidWaveNoi);
  448.     delay(6);
  449.   }
  450.   freqsid(sidVoice1,0);
  451. }
  452.  
  453. void explodesound(void)
  454. {
  455.   volumesid(15,0);
  456.   envelopesid(sidVoice1,0,0,15,11);
  457.   freqsid(sidVoice1,200);
  458.   attacksid(sidVoice1,sidWaveNoi);
  459.   delay(8);
  460.   releasesid(sidVoice1,sidWaveNoi);
  461.   delay(2400);
  462.   freqsid(sidVoice1,0);
  463. }
  464.  
  465. void bombdropsound(void)
  466. {
  467.   ushort I;
  468.  
  469.   volumesid(15,0);
  470.   envelopesid(sidVoice3,13,0,15,0);
  471.   freqsid(sidVoice3,0);
  472.   attacksid(sidVoice3,sidWaveTri);
  473.   for(I = 32000; I > 200; I -= 200)
  474.   {
  475.     freqsid(sidVoice3,I);
  476.     delay(18);
  477.   }
  478.   releasesid(sidVoice3,sidWaveTri);
  479.   delay(6);
  480.   freqsid(sidVoice3,0);
  481. }
  482.  
  483. void soundseq(uchar Rect[], uchar Seq)
  484. {
  485.   scrollupvdc(Rect[0]+1,Rect[1]+2,Rect[2]-1,Rect[3]-1);
  486.   fillattrvdc(Rect[0]+2,Rect[3]-3,Rect[2]-Rect[0]-2,appSoundTxt2Co);
  487.   printstrvdc(Rect[0]+2,Rect[3]-2,appSoundTxt1Co,appSoundSeq[Seq]);
  488. }
  489.  
  490. void soundwin(uchar Rect[])
  491. {
  492.   uchar I;
  493.  
  494.   winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appSoundWinCo,"SID Sound Effects");
  495.   for(I = 0; I < 4; I++)
  496.   {
  497.     soundseq(Rect,I);
  498.     switch (I)
  499.     {
  500.       case 0 :
  501.         planesound();
  502.         break;
  503.       case 1 :
  504.         shotssound();
  505.         break;
  506.       case 2 :
  507.         bombdropsound();
  508.         break;
  509.       case 3 :
  510.         explodesound();
  511.         break;
  512.     }
  513.   }
  514.   drawmenu(appMenuRect);
  515. }
  516.  
  517. void controlswin(uchar Rect[])
  518. {
  519.   char  StrBuf[45];
  520.  
  521.   winvdc(Rect[0],Rect[1],Rect[2],Rect[3],appCtrlWinCo,"Controls");
  522.   printstrvdc(Rect[0]+2,Rect[1]+2,appCtrlTxt1Co,"Keyboard   0   1   2   3   4   5   6   7   8   9   10 ");
  523.   printstrvdc(Rect[0]+2,Rect[1]+4,appCtrlTxt1Co,"Joystick   1   2  ");
  524.   printstrvdc(Rect[0]+2,Rect[1]+6,appCtrlTxt1Co,"Paddle     1   2   3   4  ");
  525.   printstrvdc(Rect[0]+2,Rect[1]+8,appCtrlTxt1Co,"1351 Mouse X1  Y1  X2  Y2 ");
  526.   printstrvdc(Rect[0]+21,Rect[1]+11,appCtrlTxt2Co | vdcBlink,
  527.   " [RUN STOP] to exit ");
  528. #asm
  529.   di
  530. #endasm
  531.   do
  532.   {
  533.     getpotssid();  /* read controls */
  534.     getmousesid();
  535.     getjoyscia();
  536.     getkeyscia();
  537.  
  538.     sprintf(StrBuf,"%4u%4u%4u%4u%4u%4u%4u%4u%4u%4u%4u",
  539.     ciaKeyScan[0],ciaKeyScan[1],ciaKeyScan[2],ciaKeyScan[3],
  540.     ciaKeyScan[4],ciaKeyScan[5],ciaKeyScan[6],ciaKeyScan[7],
  541.     ciaKeyScan[8],ciaKeyScan[9],ciaKeyScan[10]);
  542.     printstrvdc(Rect[0]+12,Rect[1]+3,appCtrlTxt2Co,StrBuf);
  543.  
  544.     sprintf(StrBuf,"%4u%4u",ciaJoy1,ciaJoy2);
  545.     printstrvdc(Rect[0]+12,Rect[1]+5,appCtrlTxt2Co,StrBuf);
  546.  
  547.     sprintf(StrBuf,"%4u%4u%4u%4u",sidPot1X,sidPot1Y,sidPot2X,sidPot2Y);
  548.     printstrvdc(Rect[0]+12,Rect[1]+7,appCtrlTxt2Co,StrBuf);
  549.  
  550.     sprintf(StrBuf,"%4u%4u%4u%4u",sidMouse1X,sidMouse1Y,sidMouse2X,sidMouse2Y);
  551.     printstrvdc(Rect[0]+12,Rect[1]+9,appCtrlTxt2Co,StrBuf);
  552.   }
  553.   while(ciaKeyScan[7] != 127);
  554. #asm
  555.   ei
  556. #endasm
  557.   drawmenu(appMenuRect);
  558. }
  559.  
  560. void dispclock(void)
  561. {
  562.   ciaTODStr TODStr;
  563.  
  564.   gettodcia(cia1,appTOD);
  565.   todstrcia(appTOD,TODStr);
  566.   printstrvdc(53,0,appClockCo,TODStr);
  567.   gettodcia(cia2,appTOD);
  568.   todstrcia(appTOD,TODStr);
  569.   TODStr[8] = 0;                          /* get rid of am/pm extension */
  570.   printstrvdc(71,0,appClockCo,TODStr);
  571. }
  572.  
  573. void init(void)
  574. {
  575.   settodcia(cia2,appTOD);
  576.   clearsid();
  577.   savevdc();
  578.   mapvdc();
  579.   appChSetBufPtr = NULL;
  580. }
  581.  
  582. void run(void)
  583. {
  584.   char  InKey;
  585.  
  586.   winvdc(21,5,58,10,vdcAltChrSet+vdcDarkGreen,"Info");
  587.   printstrvdc(23,7,vdcAltChrSet+vdcBlink+vdcLightGreen,
  588.   "Saving character sets to buffer");
  589.   if(savechrsets())     /* check if vdc in 16k mode */
  590.   {
  591.     drawmenu(appMenuRect);
  592.     do
  593.     {
  594.       while (!(kbhit()))
  595.         dispclock();
  596.       InKey = toupper(getch());
  597.       switch (InKey)
  598.       {
  599.         case 'A':
  600.           soundwin(appSoundRect);
  601.           break;
  602.         case 'B':
  603.           controlswin(appControlRect);
  604.           break;
  605.         case 'C':
  606.           ilace80x50text();
  607.           break;
  608.         case 'D':
  609.           drawlines();
  610.           break;
  611.         case 'E':
  612.           drawcircles();
  613.           break;
  614.         case 'F':
  615.           drawhouse();
  616.           break;
  617.         case 'G':
  618.           drawcolors();
  619.           break;
  620.         case 'S':
  621.           set64kmode();
  622.           break;
  623.       }
  624.     }
  625.     while (InKey != 'X');
  626.   }
  627. }
  628.  
  629. void done(void)
  630. {
  631.   clearsid();
  632.   if(appChSetBufPtr != NULL)
  633.     free(appChSetBufPtr);
  634.   restorevdc();     /* restore registers saved by savevdc() */
  635.   putchar(0x1A);    /* adm-3a clear-home cursor */
  636. }
  637.