home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 25 / CD_ASCQ_25_1095.iso / dos / prg / dwstk200 / err.c < prev    next >
C/C++ Source or Header  |  1995-07-25  |  9KB  |  308 lines

  1. /******************************************************************************
  2. File:          err.c
  3. Version:     2.00
  4. Tab stops: every 2 columns
  5. Project:     any STK related code
  6. Copyright: 1994-1995 DiamondWare, Ltd.    All rights reserved.*
  7. Written:     Keith Weiner & Erik Lorenzen
  8. Purpose:     Contains a routine to handle any error generated by the STK
  9. History:     94/10/21 KW Started
  10.                      95/02/21 EL Finalized for 1.00
  11.                      95/03/18 EL Added new error to err_Display(), dws_BUSY
  12.                      95/03/22 EL Finalized for 1.01
  13.                      95/04/06 EL Added new error to err_Display(), dws_MUSTBECLI
  14.                      95/04/11 EL moved DisplayError to err.c (err_Display).
  15.                      95/04/12 EL Finalized for 1.02
  16.                      95/06/16 EL Finalized for 1.03
  17.                      95/07/02 EL Added new errors dws_NOMEM & dws_NOTRESIDENT
  18.                      95/07/23 EL Finalized for 2.00, added a getch()
  19. Notes
  20. -----
  21. *Permission is expressely granted to use err_Display or any derivitive made
  22.  from it to registered users of the STK.
  23. ******************************************************************************/
  24.  
  25.  
  26.  
  27. #include <conio.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30.  
  31. #include "dws.h"
  32. #include "err.h"
  33.  
  34.  
  35.  
  36. void err_Display(word errornum)
  37. {
  38.     switch (errornum)
  39.     {
  40.         case dws_EZERO:
  41.         {
  42.             /*
  43.              . This should not have happened, considering how we got here!
  44.             */
  45.             printf("I'm confused!  Where am I?  HOW DID I GET HERE????\n");
  46.             printf("The ERROR number is: %d\n",errornum);
  47.  
  48.             break;
  49.         }
  50.         case dws_NOTINITTED:
  51.         {
  52.             /*
  53.              . If we get here, it means you haven't called dws_Init().
  54.              . The STK needs to initialize itself and the hardware before
  55.              . it can do anything.
  56.             */
  57.             printf("The STK was not initialized\n");
  58.  
  59.             break;
  60.         }
  61.         case dws_ALREADYINITTED:
  62.         {
  63.             /*
  64.              . If we get here, it means you've called dws_Init() already.  Calling
  65.              . dws_DetectHardWare at this point would cause zillions of
  66.              . problems if we let the call through.
  67.             */
  68.             printf("The STK was already initialized\n");
  69.  
  70.             break;
  71.         }
  72.         case dws_NOTSUPPORTED:
  73.         {
  74.             /*
  75.              . If we get here, it means that either the user's machine does not
  76.              . support the function you just called, or the STK was told not to
  77.              . support it in dws_Init.
  78.             */
  79.             printf("Function not supported\n");
  80.  
  81.             break;
  82.         }
  83.         case dws_DetectHardware_UNSTABLESYSTEM:
  84.         {
  85.             /*
  86.              . Please report it to DiamondWare if you get here!
  87.              .
  88.              . Ideally, you would disable control-C here, so that the user can't
  89.              . hit control-alt-delete, causing SmartDrive to flush its (possibly
  90.              . currupt) buffers.
  91.             */
  92.             printf("The system (or DOS box) is unstable!\n");
  93.             printf("If not in a multitasking system, please power down now!");
  94.  
  95.             InfiniteLoop:
  96.                 goto InfiniteLoop;
  97.         }
  98.  
  99.         /*
  100.          . The following three errors are USER/PROGRAMMER errors.  You forgot
  101.          . to fill the cardtyp struct full of -1's (except in those fields
  102.          . you intended to override, or the user (upon the unlikly event that
  103.          . the STK was unable to find a card) gave you a bad overide value.
  104.         */
  105.         case dws_DetectHardware_BADBASEPORT:
  106.         {
  107.             /*
  108.              . You set dov.baseport to a bad value, or
  109.              . didn't fill it with a -1.
  110.             */
  111.             printf("Bad port address\n");
  112.  
  113.             break;
  114.         }
  115.         case dws_DetectHardware_BADDMA:
  116.         {
  117.             /*
  118.              . You set dov.digdma to a bad value, or
  119.              . didn't fill it with a -1.
  120.             */
  121.             printf("Bad DMA channel\n");
  122.  
  123.             break;
  124.         }
  125.         case dws_DetectHardware_BADIRQ:
  126.         {
  127.             /*
  128.              . You set dov.digirq to a bad value, or
  129.              . didn't fill it with a -1.
  130.             */
  131.             printf("Bad IRQ level\n");
  132.  
  133.             break;
  134.         }
  135.         case dws_Kill_CANTUNHOOKISR:
  136.         {
  137.             /*
  138.              . The STK points the interrupt vector for the sound card's IRQ
  139.              . to its own code in dws_Init.
  140.              .
  141.              . dws_Kill was unable to restore the vector to its original
  142.              . value because other code has hooked it after the STK
  143.              . initialized(!)  This is really bad.    Make the user get rid
  144.              . of it and call dws_Kill again.
  145.             */
  146.             printf("Get rid of your TSR, pal!\n");
  147.             printf("(Press any key)\n");
  148.             getch();
  149.  
  150.             break;
  151.         }
  152.         case dws_X_BADINPUT:
  153.         {
  154.             /*
  155.              . The mixer funtions can only accept volumes between 0 & 255,
  156.              . the volume will remain unchanged.
  157.             */
  158.             printf("Bad mixer level\n");
  159.  
  160.             break;
  161.         }
  162.         case dws_D_NOTADWD:
  163.         {
  164.             /* You passed the STK a pointer to something which is not a .DWD file! */
  165.             printf("The file you are attempting to play is not a .DWD\n");
  166.  
  167.             break;
  168.         }
  169.         case dws_D_NOTSUPPORTEDVER:
  170.         {
  171.             /*
  172.              . The STK can't play a .DWD converted using a version of VOC2DWD.EXE
  173.              . newer than itself.  And, although we'll try to maintain backwards
  174.              . compatibility, we may not be able to guarantee that newer versions
  175.              . of the code will be able to play older .DWD files.  In any event,
  176.              . it's a good idea to always convert .VOC files with the utility
  177.              . which comes with the library you're linking into your application.
  178.             */
  179.             printf("Please reconvert this file using the VOC2DWD.EXE which came with this library");
  180.  
  181.             break;
  182.         }
  183.         case dws_D_INTERNALERROR:
  184.         {
  185.             /*
  186.              . This error should never occur and probably will not affect sound
  187.              . play(?).  If it happens please contact DiamondWare.
  188.             */
  189.             printf("An internal error has occured\nPlease contact DiamondWare\n");
  190.  
  191.             break;
  192.         }
  193.         case dws_DPlay_NOSPACEFORSOUND:
  194.         {
  195.             /*
  196.              . This error is more like a warning, though it may happen on a
  197.              . regular basis, depending on how many sounds you told the STK
  198.              . to allow in dws_Init, how you chose to prioritize sounds and
  199.              . how many sounds are currently being played.
  200.             */
  201.             printf("No more room for new digitized sounds right now\n");
  202.  
  203.             break;
  204.         }
  205.         case dws_DSetRate_FREQTOLOW:
  206.         {
  207.             /*
  208.              . The STK will set rate as close as possible to the indicated rate
  209.              . but cannot set a rate that low.
  210.             */
  211.             printf("Playback frequency too low\n");
  212.  
  213.             break;
  214.         }
  215.         case dws_DSetRate_FREQTOHIGH:
  216.         {
  217.             /*
  218.              . The STK will set rate as close as possible to the indicated rate
  219.              . but cannot set a rate that high.
  220.             */
  221.             printf("Playback frequency too high\n");
  222.  
  223.             break;
  224.         }
  225.         case dws_MPlay_NOTADWM:
  226.         {
  227.             /*
  228.              . You passed the STK a pointer to something which is not a .DWM file!
  229.             */
  230.             printf("The file you are attempting to play is not a .DWM\n");
  231.  
  232.             break;
  233.         }
  234.         case dws_MPlay_NOTSUPPORTEDVER:
  235.         {
  236.             /*
  237.              . The STK can't play a .DWM converted using a version of VOC2DWM.EXE
  238.              . newer than itself.  And, although we'll try to maintain backwards
  239.              . compatibility, we may not be able to guarantee that newer versions
  240.              . of the code will be able to play older .DWM files.  In any event,
  241.              . it's a good idea to always convert .MID files with the utility
  242.              . which comes with the library you're linking into your application.
  243.             */
  244.             printf("Please reconvert this file using the MID2DWM.EXE which came with this library");
  245.  
  246.             break;
  247.         }
  248.         case dws_MPlay_INTERNALERROR:
  249.         {
  250.             /*
  251.              . This error should never occur and probably will not affect sound
  252.              . play(?).  If it happens please contact DiamondWare.
  253.             */
  254.             printf("An internal error has occured\nPlease contact DiamondWare\n");
  255.  
  256.             break;
  257.         }
  258.         case dws_BUSY:
  259.         {
  260.             /*
  261.              . Can only occur when DWS is being called from the background
  262.              . (within an ISR--possibly timer or keyboard handler.)  If you get
  263.              . this error, do your IRET, and call again from your next interrupt.
  264.              . Repeat until successful.
  265.             */
  266.             printf("DWS is busy now, please call again later.");
  267.         }
  268.         case dws_IRQDISABLED:
  269.         {
  270.          /*
  271.             . The following error may be triggered by dws_Init, dws_Kill,
  272.             . or dws_DetectHardWare.    It occurs if interrupts are disabled.
  273.             . Enable interrupts (execute the STI instruction) and call again.
  274.          */
  275.             printf("Interrupts are disabled.\n");
  276.             break;
  277.         }
  278.         case dws_NOMEM:
  279.         {
  280.             /*
  281.              . The following error will occur if the STK cannot allocate enough
  282.              . DOS (real-mode) memory.
  283.             */
  284.             printf("Insufficient DOS memory.\n");
  285.             break;
  286.         }
  287.         case dws_NOTRESIDENT:
  288.         {
  289.             /* The real-mode STK component has not been installed. */
  290.             printf("The STK driver is not resident.\n");
  291.             break;
  292.         }
  293.         default:
  294.         {
  295.             /*
  296.              . If this function was clipped intact from err.c, this case
  297.              . should never occur and probably will not affect sound play(?)
  298.              . If it happens please contact DiamondWare.
  299.             */
  300.             printf("I'm confused!  Where am I?  HOW DID I GET HERE????\n");
  301.             printf("The ERROR number is: %d\n",errornum);
  302.         }
  303.     }
  304.  
  305.     printf("\n\nPress any key to continue..\n\n");
  306.     getch();
  307. }
  308.