home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / PASSDK30.ZIP;1 / DISK1.ZIP / PAS / SUBS / MISC / INITHW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-03  |  5.0 KB  |  197 lines

  1. /*$Author:   DCODY  $*/
  2. /*$Date:   03 Feb 1993 12:05:32  $*/
  3. /*$Header:   X:/sccs/misc/inithw.c_v   1.5   03 Feb 1993 12:05:32   DCODY  $*/
  4. /*$Log:   X:/sccs/misc/inithw.c_v  $
  5.  * 
  6.  *    Rev 1.5   03 Feb 1993 12:05:32   DCODY
  7.  * changed the call to mvGetHWVersion so it saves AX,CX after the call.
  8.  * 
  9.  *    Rev 1.4   24 Sep 1992 08:49:42   DCODY
  10.  * changed MVGetHardware to mvGetHardware
  11.  * 
  12.  *    Rev 1.3   20 Jul 1992 11:45:58   DCODY
  13.  * changed mvGetHWVersion call to request relocatable I/O detection.
  14.  * 
  15.  *    Rev 1.2   17 Jul 1992 14:10:32   DCODY
  16.  * major re-write for new Pro Audio cards
  17.  * 
  18.  *    Rev 1.1   23 Jun 1992 16:33:12   DCODY
  19.  * PAS2 update
  20.  * 
  21.  *    Rev 1.0   15 Jun 1992 09:39:54   BCRANE
  22.  * Initial revision.
  23. */
  24. /*$Logfile:   X:/sccs/misc/inithw.c_v  $*/
  25. /*$Modtimes$*/
  26.  
  27.     /*\
  28.     |*|----====< INITHW.C >====----
  29.     |*|
  30.     |*| This module initializes the Pro Audio Spectrum from a cold boot
  31.     |*|
  32.     |*| Copyright (c) 1991, Media Vision, Inc. All rights reserved.
  33.     |*|
  34.     \*/
  35.  
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <malloc.h>
  39.  
  40. #include "state.h"
  41. #include "mixers.h"
  42. #include "binary.h"
  43. #include "common.h"
  44. #include "target.h"
  45.  
  46.  
  47.     /* initial volume control states                                        */
  48.  
  49.     static unsigned char volumes[6][2] = {
  50.           0,  BI_VOLLOUD,            /*     0% - switch off                    */
  51.           0,  BI_VOLENHANCE,        /*     0% - switch off                    */
  52.          50,  BI_VOLBASS,            /*    50% - sliding scale                 */
  53.          50,  BI_VOLTREBLE,         /*    50% - sliding scale                 */
  54.          45,  BI_VOLLEFT,            /*    45% - sliding scale                 */
  55.          45,  BI_VOLRIGHT            /*    45% - sliding scale                 */
  56.     };
  57.  
  58.     static unsigned char mixersetting[16][3] = {
  59.          88,  BI_INPUTMIXER, BI_L_FM,        /* 88% of the sliding scale     */
  60.          88,  BI_INPUTMIXER, BI_R_FM,        /* 88% of the sliding scale     */
  61.  
  62.          55,  BI_OUTPUTMIXER, BI_L_IMIXER,    /* 55% of the sliding scale     */
  63.          55,  BI_OUTPUTMIXER, BI_R_IMIXER,    /* 55% of the sliding scale     */
  64.  
  65.          88,  BI_INPUTMIXER, BI_L_EXT,        /* 88% of the sliding scale     */
  66.          88,  BI_INPUTMIXER, BI_R_EXT,        /* 88% of the sliding scale     */
  67.  
  68.          88,  BI_INPUTMIXER, BI_L_INT,        /* 88% of the sliding scale     */
  69.          88,  BI_INPUTMIXER, BI_R_INT,        /* 88% of the sliding scale     */
  70.  
  71.          40,  BI_INPUTMIXER, BI_L_MIC,        /* 40% of the sliding scale     */
  72.          40,  BI_INPUTMIXER, BI_R_MIC,        /* 40% of the sliding scale     */
  73.  
  74.          88,  BI_INPUTMIXER, BI_L_PCM,        /* 88% of the sliding scale     */
  75.          88,  BI_INPUTMIXER, BI_R_PCM,        /* 88% of the sliding scale     */
  76.  
  77.          88,  BI_INPUTMIXER, BI_L_SPEAKER,    /* 88% of the sliding scale     */
  78.          88,  BI_INPUTMIXER, BI_R_SPEAKER,    /* 88% of the sliding scale     */
  79.  
  80.          88,  BI_INPUTMIXER, BI_L_SBDAC,    /* 88% of the sliding scale     */
  81.          88,  BI_INPUTMIXER, BI_R_SBDAC     /* 88% of the sliding scale     */
  82.  
  83.     };
  84.  
  85.  
  86.     /*\
  87.     |*|----====< int InitMVHardware( ) >====----
  88.     |*|
  89.     |*| This code initializes the ProAudio Spectrum mixer, volume,
  90.     |*| MIDI, FM, and PCM hardware to default states.
  91.     |*|
  92.     |*| Entry Conditions:
  93.     |*|     None
  94.     |*|
  95.     |*| Exit Conditions:
  96.     |*|     returns the hardware version of the card (currently 0)
  97.     |*|
  98.     \*/
  99. int InitMVHardware()
  100. {
  101. int n,i,x,hv,hvbits;
  102. int mvGetHWVersion(int);
  103.  
  104.     /* determine the feature set of this board                                */
  105.  
  106.         mvGetHWVersion(USE_ACTIVE_ADDR);
  107.         _asm {
  108.             mov     hv,ax
  109.             mov     hvbits,cx
  110.         }
  111.  
  112.     /* blow off the interrupts                                              */
  113.  
  114.         MVOut (INTRCTLR, 0xFF,0x00);
  115.  
  116.     /* take the board out of reset by writing a value to the filter         */
  117.  
  118.         MVOut(AUDIOFILT,0xFF,0x00);
  119.  
  120.     /* set the cross channel to LEFT-TO-LEFT, RIGHT-TO-RIGHT & kill PCM     */
  121.  
  122.         MVOut (CROSSCHANNEL,0xFF, bCCl2l+bCCr2r);
  123.  
  124.     /* initialize access to the mixers                                        */
  125.  
  126.         MVInitMixerCode(0);
  127.  
  128.     /* initialize the volume device                                         */
  129.  
  130.         for (n=0;n<6;n++)
  131.             cMVSetVolumeFunction(volumes[n][0], volumes[n][1]);
  132.  
  133.     /* initialize the input mixer for all channels                            */
  134.  
  135.         for (n=0;n<16;n++)
  136.             cMVSetMixerFunction
  137.               (
  138.                 mixersetting[n][0],
  139.                 mixersetting[n][1],
  140.                 mixersetting[n][2]
  141.               );
  142.  
  143.     /* turn off the realsound switch                                        */
  144.  
  145.         cMVRealSoundSwitch (0,1);
  146.  
  147.     /* set the FM into mono access mode, then flush them...                 */
  148.  
  149.         cMVFMSplitSwitch   (100,1);
  150.  
  151.         for (n=0;n<256;n++) {
  152.  
  153.             outp (0x388,n);
  154.  
  155.             for(x=i=0;i<3;i++)
  156.                 x += inp(0x388);
  157.  
  158.             outp (0x389,0);
  159.  
  160.             for(x=i=0;i<33;i++)
  161.                 x += inp(0x388);
  162.         }
  163.  
  164.     /* flush the MIDI interface                                             */
  165.  
  166.         if (hvbits & bMV101) {
  167.  
  168.             MVOut(MIDIPRESCALE, 0xFF,0x00);
  169.             MVOut(MIDICONTROL,    0xFF,bMCRrstfifoi+bMCRrstfifoi);
  170.             MVOut(MIDICONTROL,  0xFF,0x00);
  171.  
  172.         }
  173.         else {
  174.  
  175.             MVOut(MDSYSCTLR,0xFF,0x80);     // send a reset to the Yamaha
  176.  
  177.             for(x=i=0;i<33;i++)             // wait 80 microseconds
  178.                 x += inp(0x388);
  179.  
  180.             MVOut(MDSYSCTLR,0xFF,0x80);     // clear the reset
  181.  
  182.         }
  183.  
  184.     /* take the board out of reset by writing a value to the filter         */
  185.  
  186.         cMVSetFilterFunction(100);        /* set for no limiting                */
  187.  
  188.     /* return the hardware version #                                        */
  189.  
  190.         return (hv);
  191. }
  192.  
  193.     /*\
  194.     |*| end of INITHW.C
  195.     \*/
  196.  
  197.