home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / cs0929a.zip / wavaudio.lst < prev    next >
File List  |  1999-09-29  |  46KB  |  1,083 lines

  1.  
  2. Module: D:\dev\csrc\os2dd\scd\wavaudio.c
  3. Group: 'DGROUP' CONST,CONST2,_DATA,_BSS,_INITDATA
  4.  
  5. Segment: _TEXT  PARA   0000045c bytes  
  6.  
  7. //
  8. // wavaudio.c
  9. // 27-Jan-99
  10. //
  11. // VOID   waDevCaps(MCI_AUDIO_CAPS __far *devCapsPtr, WAVEAUDIO *waPtr);
  12. // VOID   waConfigDev(WAVECONFIG *waveConfigPtr, WAVEAUDIO *waPtr);
  13. // USHORT waPause(VOID);
  14. // USHORT waResume(VOID);
  15. // USHORT waSetup(USHORT dmaChannel, WAVEAUDIO *waPtr);
  16. //
  17. // _usfind_matching_sample_rate() and
  18. // _vset_clock_info() only called here, once, so done at caller rather than separate routines
  19.  
  20. #include "cs40.h"
  21.  
  22. // local defines for PCM, muLAW, and aLAW tables used by virtual void DevCaps(PAUDIO_CAPS pCaps)
  23.  
  24. #define NUMFREQS   4
  25. #define BPSTYPES   2
  26. #define MONOSTEREO 2
  27.  
  28. // local sample rate to clock-select bits
  29.  
  30. typedef struct _SRT {
  31.  USHORT sampleRate;     // 00 (was ULONG)
  32.  UCHAR  clockSelect;    // 02
  33.  UCHAR  rsv3;           // 03 reserved (can be used as multiplier flag for freq if need freq > 65535)
  34. } SRT;
  35.  
  36. // This table holds all the sample rates the CS4232 can operate at and the data required
  37. // in bits 0-3 of the FS and Playback Data Format Reg, (indexed register 8) to set them up
  38.  
  39. static SRT srt[] = {
  40.   5512,0x01,0,  6615,0x0f,0,  8000,0x00,0,  9600,0x0e,0, 11025,0x03,0,
  41.  16000,0x02,0, 18900,0x05,0, 22050,0x07,0, 27428,0x04,0, 32000,0x06,0,
  42.  33075,0x0D,0, 37800,0x09,0, 44100,0x0B,0, 48000,0x0C,0};
  43.  
  44. #define SRT_COUNT (sizeof(srt)/sizeof(SRT))
  45.  
  46. // the following 3-D array defines the subtypes for DATATYPE_WAVEFORM
  47. // The array is 4x2x2 and is indexed using frequency index, bits per
  48. // sample being 8 or 16 represented by 0 or 1 resp. and mono or stereo
  49. // mode represented by 0 or 1 respectively. For eg. to find out the
  50. // subtype for 22050Hz sampling frequency, using 16 bits per sample
  51. // and stereo mode, we use waveSubtypes[FREQ22KHZ][BPS16][1].
  52.  
  53. static USHORT waveSubtypes[NUMFREQS][BPSTYPES][MONOSTEREO] = { // was ULONG
  54.  WAVE_FORMAT_1M08,    // 11.025kHz, 8-bit  Mono
  55.  WAVE_FORMAT_1S08,    // 11.025kHz, 8-bit  Stereo
  56.  WAVE_FORMAT_1M16,    // 11.025kHz, 16-bit Mono
  57.  WAVE_FORMAT_1S16,    // 11.025kHz, 16-bit Stereo
  58.  WAVE_FORMAT_2M08,    // 22.05kHz , 8-bit  Mono
  59.  WAVE_FORMAT_2S08,    // 22.05kHz , 8-bit  Stereo
  60.  WAVE_FORMAT_2M16,    // 22.05kHz , 16-bit Mono
  61.  WAVE_FORMAT_2S16,    // 22.05kHz , 16-bit Stereo
  62.  WAVE_FORMAT_4M08,    // 44.1kHz  , 8-bit  Mono
  63.  WAVE_FORMAT_4S08,    // 44.1kHz  , 8-bit  Stereo
  64.  WAVE_FORMAT_4M16,    // 44.1kHz  , 16-bit Mono
  65.  WAVE_FORMAT_4S16,    // 44.1kHz  , 16-bit Stereo
  66.  WAVE_FORMAT_8M08,    //  8.0kHz  , 8-bit  Mono
  67.  WAVE_FORMAT_8S08,    //  8.0kHz  , 8-bit  Stereo
  68.  WAVE_FORMAT_8M16,    //  8.0kHz  , 16-bit Mono
  69.  WAVE_FORMAT_8S16     //  8.0kHz  , 16-bit Stereo
  70. };
  71.  
  72. // the following 2-D array defines the subtypes for DATATYPE_ALAW  it is indexed by the
  73. // sampling rate ordinal (from _usfind_matching_sample_rate) and the number of channels
  74.  
  75. static USHORT aLaw[NUMFREQS][MONOSTEREO] = { // was ULONG
  76.  ALAW_8B11KM,      // 8bit 11kHz mono
  77.  ALAW_8B11KS,      // 8bit 11kHz stereo
  78.  ALAW_8B22KM,      // 8bit 22kHz mono
  79.  ALAW_8B22KS,      // 8bit 22kHz stereo
  80.  ALAW_8B44KM,      // 8bit 44kHz mono
  81.  ALAW_8B44KS,      // 8bit 44kHz stereo
  82.  ALAW_8B8KM ,      // 8bit 8kHz mono
  83.  ALAW_8B8KS        // 8bit 8kHz stereo
  84. };
  85.  
  86. // the following 2-D array defines the subtypes for DATATYPE_MULAW it is indexed by the
  87. // sampling rate ordinal (from _usfind_matching_sample_rate) and the number of channels
  88.  
  89. static USHORT muLaw[NUMFREQS][MONOSTEREO] = { // was ULONG
  90.  MULAW_8B11KM,     // 8bit 11kHz mono
  91.  MULAW_8B11KS,     // 8bit 11kHz stereo
  92.  MULAW_8B22KM,     // 8bit 22kHz mono
  93.  MULAW_8B22KS,     // 8bit 22kHz stereo
  94.  MULAW_8B44KM,     // 8bit 44kHz mono
  95.  MULAW_8B44KS,     // 8bit 44kHz stereo
  96.  MULAW_8B8KM ,     // 8bit 8kHz mono
  97.  MULAW_8B8KS       // 8bit 8kHz stereo
  98. };
  99.  
  100. // sampleRates[] used by _usfind_matching_sample_rate() to determine sampling rate ordinal
  101.  
  102. USHORT sampleRates[] = {11025, 22050, 44100, 8000};  // all that's supported!? (yes, weird order)
  103.  
  104. #define SR_COUNT (sizeof(sampleRates)/sizeof(USHORT))
  105.  
  106. // following takes positive arguments and returns the absolute difference between the two args
  107.  
  108. #define DELTA(x,y) ((x > y) ? x - y : y - x)
  109.  
  110.  
  111. // --------------------
  112. // in: devCapsPtr -> audio caps structure passed from IoctlAudioCapability() call (was PAUDIO_CAPS, in audio.h)
  113. //out: n/a
  114. //nts:
  115.  
  116. VOID waDevCaps(MCI_AUDIO_CAPS __far *devCapsPtr) {
  117.  
  118.  USHORT sampleRate;
  119.  0000  53                waDevCaps_      push    bx
  120.  0001  51                                push    cx
  121.  0002  56                                push    si
  122.  0003  57                                push    di
  123.  0004  55                                push    bp
  124.  0005  89 e5                             mov     bp,sp
  125.  0007  83 ec 08                          sub     sp,0008H
  126.  000a  89 c7                             mov     di,ax
  127.  000c  89 56 fe                          mov     [bp-2H],dx
  128.  
  129.  USHORT sampleRateIndex = 0;
  130.  USHORT tbps, tch, isFD;
  131.  
  132.  000f  31 d2                             xor     dx,dx
  133.  
  134.  if (devCapsPtr->ulOperation == OPERATION_RECORD) {
  135.  0011  8e 46 fe                          mov     es,[bp-2H]
  136.  0014  89 56 fa                          mov     [bp-6H],dx
  137.  0017  26 8b 5d 16                       mov     bx,es:[di+16H]
  138.  001b  26 8b 4d 14                       mov     cx,es:[di+14H]
  139.  001f  85 db                             test    bx,bx
  140.  0021  75 0a                             jne     L1
  141.  0023  83 f9 02                          cmp     cx,0002H
  142.  0026  75 05                             jne     L1
  143.  
  144.     isFD = war.flags & FLAGS_WAVEAUDIO_FULLDUPLEX;
  145.  }
  146.  0028  a1 00 00                          mov     ax,_war
  147.  
  148.  else if (devCapsPtr->ulOperation == OPERATION_PLAY) {
  149.     isFD = wap.flags & FLAGS_WAVEAUDIO_FULLDUPLEX;
  150.  }
  151.  else {
  152.  002b  eb 1d                             jmp     L4
  153.  002d  26 8b 45 14       L1              mov     ax,es:[di+14H]
  154.  0031  85 db                             test    bx,bx
  155.  0033  75 05                             jne     L2
  156.  0035  3d 01 00                          cmp     ax,0001H
  157.  0038  74 0d                             je      L3
  158.  
  159.     devCapsPtr->ulSupport = UNSUPPORTED_OPERATION;      // (since can't record+play on SAME stream)
  160.  003a  26 c7 45 18 10 00 L2              mov     word ptr es:[di+18H],0010H
  161.  0040  26 89 55 1a                       mov     es:[di+1aH],dx
  162.  
  163.     return;
  164.  0044  e9 7e 02                          jmp     L30
  165.  
  166.  }
  167.  
  168.  0047  a1 00 00          L3              mov     ax,_wap
  169.  004a  30 e4             L4              xor     ah,ah
  170.  004c  24 01                             and     al,01H
  171.  004e  89 46 f8                          mov     [bp-8H],ax
  172.  
  173.  if (devCapsPtr->ulChannels > 2) {
  174.  0051  8e 46 fe                          mov     es,[bp-2H]
  175.  0054  26 8b 55 0a                       mov     dx,es:[di+0aH]
  176.  0058  26 8b 5d 08                       mov     bx,es:[di+8H]
  177.  005c  85 d2                             test    dx,dx
  178.  005e  75 05                             jne     L5
  179.  0060  83 fb 02                          cmp     bx,0002H
  180.  0063  76 14                             jbe     L6
  181.  
  182.     devCapsPtr->ulSupport = UNSUPPORTED_CHANNELS;
  183.     return;
  184.  }
  185.  
  186.  0065  26 c7 45 18 02 00 L5              mov     word ptr es:[di+18H],0002H
  187.  006b  26 c7 45 1a 00 00                 mov     word ptr es:[di+1aH],0000H
  188.  0071  89 ec                             mov     sp,bp
  189.  0073  5d                                pop     bp
  190.  0074  5f                                pop     di
  191.  0075  5e                                pop     si
  192.  0076  59                                pop     cx
  193.  0077  5b                                pop     bx
  194.  0078  c3                                ret     
  195.  
  196.  if (devCapsPtr->ulBitsPerSample != 8 && devCapsPtr->ulBitsPerSample != 16) {
  197.  0079  26 8b 4d 0e       L6              mov     cx,es:[di+0eH]
  198.  007d  26 8b 75 0c                       mov     si,es:[di+0cH]
  199.  0081  85 c9                             test    cx,cx
  200.  0083  75 05                             jne     L7
  201.  0085  83 fe 08                          cmp     si,0008H
  202.  0088  74 21                             je      L9
  203.  008a  26 8b 55 0c       L7              mov     dx,es:[di+0cH]
  204.  008e  85 c9                             test    cx,cx
  205.  0090  75 05                             jne     L8
  206.  0092  83 fa 10                          cmp     dx,0010H
  207.  0095  74 14                             je      L9
  208.  
  209.     devCapsPtr->ulSupport = UNSUPPORTED_BPS;
  210.     return;
  211.  }
  212.  
  213.  0097  26 c7 45 18 04 00 L8              mov     word ptr es:[di+18H],0004H
  214.  009d  26 c7 45 1a 00 00                 mov     word ptr es:[di+1aH],0000H
  215.  00a3  89 ec                             mov     sp,bp
  216.  00a5  5d                                pop     bp
  217.  00a6  5f                                pop     di
  218.  00a7  5e                                pop     si
  219.  00a8  59                                pop     cx
  220.  00a9  5b                                pop     bx
  221.  00aa  c3                                ret     
  222.  
  223.  sampleRate = (USHORT)devCapsPtr->ulSamplingRate;
  224.  if (1) {
  225.  00ab  8e 46 fe          L9              mov     es,[bp-2H]
  226.  
  227.     USHORT i, diff, minDiff = 65535;
  228.  00ae  bb ff ff                          mov     bx,0ffffH
  229.  
  230.     for (i=0; i < (sizeof(sampleRates)/sizeof(sampleRates[0])); i++) {
  231.  00b1  31 c0                             xor     ax,ax
  232.  00b3  89 5e fc                          mov     [bp-4H],bx
  233.  00b6  26 8b 75 04                       mov     si,es:[di+4H]
  234.  00ba  31 db                             xor     bx,bx
  235.  
  236.        diff = DELTA(sampleRate, sampleRates[i]);
  237.  00bc  8b 97 00 00       L10             mov     dx,[bx+_sampleRates]
  238.  00c0  39 d6                             cmp     si,dx
  239.  00c2  76 08                             jbe     L11
  240.  00c4  89 f2                             mov     dx,si
  241.  00c6  2b 97 00 00                       sub     dx,[bx+_sampleRates]
  242.  00ca  eb 02                             jmp     L12
  243.  00cc  29 f2             L11             sub     dx,si
  244.  
  245.        if (diff < minDiff) {
  246.  00ce  3b 56 fc          L12             cmp     dx,[bp-4H]
  247.  00d1  73 06                             jae     L13
  248.  
  249.           minDiff = diff;
  250.  00d3  89 56 fc                          mov     [bp-4H],dx
  251.  
  252.           sampleRateIndex = i;
  253.  00d6  89 46 fa                          mov     [bp-6H],ax
  254.  
  255.        }
  256.  00d9  40                L13             inc     ax
  257.  
  258.     }
  259.  00da  83 c3 02                          add     bx,0002H
  260.  00dd  3d 04 00                          cmp     ax,0004H
  261.  00e0  72 da                             jb      L10
  262.  
  263.     sampleRate = sampleRates[sampleRateIndex];
  264.  00e2  8b 5e fa                          mov     bx,[bp-6H]
  265.  00e5  01 db                             add     bx,bx
  266.  00e7  8b 87 00 00                       mov     ax,[bx+_sampleRates]
  267.  
  268.     if (sampleRate != (USHORT)devCapsPtr->ulSamplingRate) {
  269.  00eb  8e 46 fe                          mov     es,[bp-2H]
  270.  00ee  26 3b 45 04                       cmp     ax,es:[di+4H]
  271.  00f2  74 28                             je      L14
  272.  
  273.        devCapsPtr->ulSamplingRate = sampleRate;                      // yup, update original
  274.  00f4  26 89 45 04                       mov     es:[di+4H],ax
  275.  
  276.        devCapsPtr->ulFlags = devCapsPtr->ulFlags | BESTFIT_PROVIDED; // ugh!
  277.  
  278. // !!!
  279.  00f8  26 8a 65 33                       mov     ah,es:[di+33H]
  280.  00fc  26 c7 45 06 00 00                 mov     word ptr es:[di+6H],0000H
  281.  0102  80 cc 40                          or      ah,40H
  282.  
  283. if (gCLflags & FLAGS_CL_DDPRINT) ddprintf("waDevCaps: using BESTFIT sampleRate\n");
  284.  
  285.     }
  286.  }
  287.  
  288.  // get ulDataSubType and update any format-specific flags
  289.  // note: all data types have more than one value
  290.  
  291.  0105  8a 16 01 00                       mov     dl,_gCLflags+1H
  292.  0109  26 88 65 33                       mov     es:[di+33H],ah
  293.  010d  f6 c2 40                          test    dl,40H
  294.  0110  74 0a                             je      L14
  295.  0112  1e                                push    ds
  296.  0113  68 00 00                          push    offset L49
  297.  0116  e8 00 00                          call    _ddprintf
  298.  0119  83 c4 04                          add     sp,0004H
  299.  
  300.  tbps = (devCapsPtr->ulBitsPerSample-8)/8;      // 0 or 1 (for 8 or 16)
  301.  tch  = devCapsPtr->ulChannels - 1;             // 0 or 1 (for mono or stereo)
  302.  
  303.  011c  8e 46 fe          L14             mov     es,[bp-2H]
  304.  011f  26 8b 45 0c                       mov     ax,es:[di+0cH]
  305.  0123  05 f8 ff                          add     ax,0fff8H
  306.  0126  26 8b 55 0e                       mov     dx,es:[di+0eH]
  307.  012a  83 d2 ff                          adc     dx,0ffffH
  308.  012d  b1 03                             mov     cl,03H
  309.  012f  d3 e8                             shr     ax,cl
  310.  0131  d3 ca                             ror     dx,cl
  311.  0133  31 d0                             xor     ax,dx
  312.  0135  81 e2 ff 1f                       and     dx,1fffH
  313.  0139  31 d0                             xor     ax,dx
  314.  
  315.  switch (devCapsPtr->ulDataType) {
  316.  case DATATYPE_WAVEFORM:
  317.  case PCM:
  318.  013b  26 8b 5d 10                       mov     bx,es:[di+10H]
  319.  013f  26 8b 4d 08                       mov     cx,es:[di+8H]
  320.  0143  26 8b 75 12                       mov     si,es:[di+12H]
  321.  0147  49                                dec     cx
  322.  0148  85 f6                             test    si,si
  323.  014a  75 05                             jne     L15
  324.  014c  83 fb 05                          cmp     bx,0005H
  325.  014f  72 3e                             jb      L20
  326.  0151  85 f6             L15             test    si,si
  327.  0153  75 07                             jne     L16
  328.  0155  83 fb 06                          cmp     bx,0006H
  329.  0158  0f 86 7c 00                       jbe     L24
  330.  015c  85 f6             L16             test    si,si
  331.  015e  75 06                             jne     L17
  332.  0160  81 fb 01 01                       cmp     bx,0101H
  333.  0164  72 1b                             jb      L19
  334.  0166  85 f6             L17             test    si,si
  335.  0168  75 08                             jne     L18
  336.  016a  81 fb 01 01                       cmp     bx,0101H
  337.  016e  0f 86 83 00                       jbe     L25
  338.  0172  85 f6             L18             test    si,si
  339.  0174  0f 85 9a 00                       jne     L26
  340.  0178  81 fb 02 01                       cmp     bx,0102H
  341.  017c  74 5a                             je      L24
  342.  017e  e9 91 00                          jmp     L26
  343.  0181  85 f6             L19             test    si,si
  344.  0183  0f 85 8b 00                       jne     L26
  345.  0187  83 fb 07                          cmp     bx,0007H
  346.  018a  74 69                             je      L25
  347.  018c  e9 83 00                          jmp     L26
  348.  018f  85 f6             L20             test    si,si
  349.  0191  75 07                             jne     L21
  350.  0193  83 fb 01                          cmp     bx,0001H
  351.  0196  0f 82 78 00                       jb      L26
  352.  019a  85 f6             L21             test    si,si
  353.  019c  75 05                             jne     L22
  354.  019e  83 fb 02                          cmp     bx,0002H
  355.  01a1  76 0b                             jbe     L23
  356.  01a3  85 f6             L22             test    si,si
  357.  01a5  75 6b                             jne     L26
  358.  01a7  83 fb 03                          cmp     bx,0003H
  359.  01aa  74 49                             je      L25
  360.  01ac  eb 64                             jmp     L26
  361.  
  362.     devCapsPtr->ulDataSubType = (ULONG)waveSubtypes[sampleRateIndex][tbps][tch];
  363.     //if (tbps) devCapsPtr->ulFlags = devCapsPtr->ulFlags | TWOS_COMPLEMENT | SIGNED; //16-bit is alway 2's-comp
  364. // !!! see if this matters
  365.  01ae  8b 5e fa          L23             mov     bx,[bp-6H]
  366.  01b1  89 c2                             mov     dx,ax
  367.  01b3  c1 e3 03                          shl     bx,03H
  368.  01b6  c1 e2 02                          shl     dx,02H
  369.  01b9  01 c9                             add     cx,cx
  370.  01bb  01 d3                             add     bx,dx
  371.  01bd  01 cb                             add     bx,cx
  372.  01bf  8b 97 00 00                       mov     dx,[bx+_waveSubtypes]
  373.  01c3  26 c7 45 1e 00 00                 mov     word ptr es:[di+1eH],0000H
  374.  01c9  26 89 55 1c                       mov     es:[di+1cH],dx
  375.  
  376.     if (tbps) devCapsPtr->ulFlags = devCapsPtr->ulFlags | TWOS_COMPLEMENT;
  377.     break;
  378.  
  379.  case DATATYPE_ALAW:
  380.  case DATATYPE_RIFF_ALAW:
  381.  case A_LAW:
  382.  01cd  85 c0                             test    ax,ax
  383.  01cf  74 58                             je      L27
  384.  01d1  26 80 4d 30 08                    or      byte ptr es:[di+30H],08H
  385.  01d6  eb 51                             jmp     L27
  386.  
  387.     devCapsPtr->ulDataSubType = (ULONG)aLaw[sampleRateIndex][tch];
  388.  01d8  8b 5e fa          L24             mov     bx,[bp-6H]
  389.  01db  01 c9                             add     cx,cx
  390.  01dd  c1 e3 02                          shl     bx,02H
  391.  01e0  01 cb                             add     bx,cx
  392.  01e2  8b 87 00 00                       mov     ax,[bx+_aLaw]
  393.  01e6  8e 46 fe                          mov     es,[bp-2H]
  394.  01e9  26 c7 45 1e 00 00                 mov     word ptr es:[di+1eH],0000H
  395.  01ef  26 89 45 1c                       mov     es:[di+1cH],ax
  396.  
  397.     break;
  398.  
  399.  case DATATYPE_MULAW:
  400.  case DATATYPE_RIFF_MULAW:
  401.  case MU_LAW:
  402.  01f3  eb 34                             jmp     L27
  403.  
  404.     devCapsPtr->ulDataSubType = (ULONG)muLaw[sampleRateIndex][tch];
  405.  01f5  8b 5e fa          L25             mov     bx,[bp-6H]
  406.  01f8  01 c9                             add     cx,cx
  407.  01fa  c1 e3 02                          shl     bx,02H
  408.  01fd  01 cb                             add     bx,cx
  409.  01ff  8b 87 00 00                       mov     ax,[bx+_muLaw]
  410.  0203  8e 46 fe                          mov     es,[bp-2H]
  411.  0206  26 c7 45 1e 00 00                 mov     word ptr es:[di+1eH],0000H
  412.  020c  26 89 45 1c                       mov     es:[di+1cH],ax
  413.  
  414.     break;
  415.  
  416.  default:
  417.  0210  eb 17                             jmp     L27
  418.  
  419.     devCapsPtr->ulSupport = UNSUPPORTED_DATATYPE;
  420.     return;
  421.  }
  422.  
  423.  // original had this overwrite the ulFlags above! (TWOS_COMP and BESTFIT_!)
  424.  // also, original (tropez) sets TWOS_COMP for 8-bit! data, in WAVESTREAM constructor
  425.  // also, original sets BIG_ENDIAN (4232 says 16-bit is little endian)
  426.  // ... not sure if this is saying what should be used, or what -can- be used (as in BIG_ENDIAN supported)
  427.  
  428. // !!!
  429.  0212  8e 46 fe          L26             mov     es,[bp-2H]
  430.  0215  26 c7 45 18 08 00                 mov     word ptr es:[di+18H],0008H
  431.  021b  26 c7 45 1a 00 00                 mov     word ptr es:[di+1aH],0000H
  432.  0221  89 ec                             mov     sp,bp
  433.  0223  5d                                pop     bp
  434.  0224  5f                                pop     di
  435.  0225  5e                                pop     si
  436.  0226  59                                pop     cx
  437.  0227  5b                                pop     bx
  438.  0228  c3                                ret     
  439.  
  440.  devCapsPtr->ulFlags = devCapsPtr->ulFlags |
  441.                               BIG_ENDIAN |      // !!! that's what tropez has
  442.                               FIXED        |  // fixed length data
  443.                               LEFT_ALIGNED |  // left align bits on byte (always is if 8/16 bps)
  444.                               INPUT        |  // input select is supported
  445.                               OUTPUT       |  // output select is supported
  446.                               MONITOR      |  // monitor is supported
  447.                               VOLUME;         // volume control is supported
  448.  
  449.  // full-duplex info:
  450.  // The number of resource units is described in the MMPM2.INI -- this can be thought of as
  451.  // the number of active streams the driver can manage at one time.   Use 2 (one play, one rec).
  452.  //
  453.  // Tell MMPM how many of these units THIS stream will consume.  If full-duplex allowed, this
  454.  // stream consumes 1 stream unit.  If not allowed, indicate that this stream consumes 2 units
  455.  // (or all the available units).
  456.  //
  457.  // Along with the resource units, 2 resources classes are defined:  one for playback and one
  458.  // for capture.  Tell MMPM (in the MMPM2.INI) that driver can deal with 1 playback and 1 capture
  459.  // stream, OR 1 capture and 1 playback stream, at the same time. This is indicated in the
  460.  // valid resource combos in MMPM2.INI
  461.  //
  462.  // So, check if this is a playback or capture and set the correct resource class
  463.  // (playback = 1, capture = 2)
  464.  //
  465.  // no longer have WAVEAUDIO.usDmaChan/usSecDmaChan, but instead just WAVEAUDIO.flags bit0=1 is F-D
  466.  
  467.  0229  8e 46 fe          L27             mov     es,[bp-2H]
  468.  022c  26 8b 75 32                       mov     si,es:[di+32H]
  469.  0230  26 8a 5d 30                       mov     bl,es:[di+30H]
  470.  0234  81 ce e0 01                       or      si,01e0H
  471.  0238  80 cb 23                          or      bl,23H
  472.  023b  26 88 5d 30                       mov     es:[di+30H],bl
  473.  
  474.  if (isFD) {
  475.     devCapsPtr->ulResourceUnits = 1;
  476.  }
  477.  else {
  478.     devCapsPtr->ulResourceUnits = 2;   // full-duplex not allowed so allocate both resource units
  479.  }
  480.  
  481.  023f  8b 56 f8                          mov     dx,[bp-8H]
  482.  0242  26 89 75 32                       mov     es:[di+32H],si
  483.  0246  85 d2                             test    dx,dx
  484.  0248  0f 94 c0                          sete    al
  485.  024b  26 8b 4d 14                       mov     cx,es:[di+14H]
  486.  024f  30 e4                             xor     ah,ah
  487.  0251  31 d2                             xor     dx,dx
  488.  0253  05 01 00                          add     ax,0001H
  489.  0256  26 89 45 20                       mov     es:[di+20H],ax
  490.  025a  11 d2                             adc     dx,dx
  491.  
  492.  if (devCapsPtr->ulOperation == OPERATION_RECORD) {
  493.  025c  26 8b 5d 16                       mov     bx,es:[di+16H]
  494.  0260  26 89 55 22                       mov     es:[di+22H],dx
  495.  0264  85 db                             test    bx,bx
  496.  0266  75 0d                             jne     L28
  497.  0268  83 f9 02                          cmp     cx,0002H
  498.  026b  75 08                             jne     L28
  499.  
  500.     devCapsPtr->ulResourceClass = 2;
  501.  }
  502.  026d  26 c7 45 24 02 00                 mov     word ptr es:[di+24H],0002H
  503.  
  504.  else {
  505.  0273  eb 06                             jmp     L29
  506.  
  507.     devCapsPtr->ulResourceClass = 1;
  508.  }
  509.  
  510.  0275  26 c7 45 24 01 00 L28             mov     word ptr es:[di+24H],0001H
  511.  027b  26 c7 45 26 00 00 L29             mov     word ptr es:[di+26H],0000H
  512.  
  513.  devCapsPtr->fCanRecord = 1;
  514.  0281  8e 46 fe                          mov     es,[bp-2H]
  515.  0284  26 c7 45 2c 01 00                 mov     word ptr es:[di+2cH],0001H
  516.  028a  26 c7 45 2e 00 00                 mov     word ptr es:[di+2eH],0000H
  517.  
  518.  devCapsPtr->ulBlockAlign = 1;
  519.  0290  26 c7 45 28 01 00                 mov     word ptr es:[di+28H],0001H
  520.  0296  26 c7 45 2a 00 00                 mov     word ptr es:[di+2aH],0000H
  521.  
  522.  devCapsPtr->ulSupport = SUPPORT_SUCCESS;
  523.  
  524. // !!!
  525.  029c  26 c7 45 18 00 00                 mov     word ptr es:[di+18H],0000H
  526.  
  527. if (gCLflags & FLAGS_CL_DDPRINT) ddprintf("@waDevCaps: devCapsPtr->ulFlags=%lx\n", devCapsPtr->ulFlags);
  528.  
  529.  return;
  530.  02a2  8a 3e 01 00                       mov     bh,_gCLflags+1H
  531.  02a6  26 c7 45 1a 00 00                 mov     word ptr es:[di+1aH],0000H
  532.  02ac  f6 c7 40                          test    bh,40H
  533.  02af  74 14                             je      L30
  534.  02b1  26 8b 75 32                       mov     si,es:[di+32H]
  535.  02b5  56                                push    si
  536.  02b6  26 8b 45 30                       mov     ax,es:[di+30H]
  537.  02ba  50                                push    ax
  538.  02bb  1e                                push    ds
  539.  02bc  68 26 00                          push    offset L50
  540.  02bf  e8 00 00                          call    _ddprintf
  541.  02c2  83 c4 08                          add     sp,0008H
  542.  
  543. }
  544.  
  545.  
  546. // ---------------------------------
  547. // in: wsPtr -> wavestream structure
  548. //out:
  549. //nts: also reinits dma hardware (esp. for logical dma buffer size, interrupts/buffer)
  550.  
  551.  02c5  89 ec             L30             mov     sp,bp
  552.  02c7  5d                                pop     bp
  553.  02c8  5f                                pop     di
  554.  02c9  5e                                pop     si
  555.  02ca  59                                pop     cx
  556.  02cb  5b                                pop     bx
  557.  02cc  c3                                ret     
  558.  02cd  89 c0                             mov     ax,ax
  559.  02cf  fc                                cld     
  560.  
  561. VOID waConfigDev(WAVESTREAM *wsPtr) {
  562.  
  563.  ULONG i, count, consumeRate;
  564.  USHORT tbps, tch, tBytesPS, tIs16, tIsST;
  565.  USHORT bufferInts;
  566.  USHORT dmaType;
  567.  
  568.  WAVECONFIG *waveConfigPtr = &wsPtr->waveConfig;
  569.  02d0  53                waConfigDev_    push    bx
  570.  02d1  51                                push    cx
  571.  02d2  52                                push    dx
  572.  02d3  56                                push    si
  573.  02d4  57                                push    di
  574.  02d5  55                                push    bp
  575.  02d6  89 e5                             mov     bp,sp
  576.  02d8  83 ec 06                          sub     sp,0006H
  577.  02db  89 c3                             mov     bx,ax
  578.  
  579.  WAVEAUDIO *waPtr = wsPtr->waPtr;
  580.  
  581. // !!! new dma stuff
  582.  
  583.  02dd  8b 77 02                          mov     si,[bx+2H]
  584.  
  585.  waPtr->ab.bufferSize = wsPtr->audioBufferSize; // dma buffer size for this stream (def=0, 16KB)
  586.  02e0  8b 47 14                          mov     ax,[bx+14H]
  587.  02e3  c7 44 1e 00 00                    mov     word ptr [si+1eH],0000H
  588.  02e8  89 44 1c                          mov     [si+1cH],ax
  589.  02eb  8d 7f 04                          lea     di,[bx+4H]
  590.  
  591.  if (waPtr->ab.bufferSize < 1024) waPtr->ab.bufferSize = 0x4000;
  592.  
  593.  02ee  8b 54 1e                          mov     dx,[si+1eH]
  594.  02f1  8b 4c 1c                          mov     cx,[si+1cH]
  595.  02f4  85 d2                             test    dx,dx
  596.  02f6  75 10                             jne     L31
  597.  02f8  81 f9 00 04                       cmp     cx,0400H
  598.  02fc  73 0a                             jae     L31
  599.  02fe  c7 44 1c 00 40                    mov     word ptr [si+1cH],4000H
  600.  0303  c7 44 1e 00 00                    mov     word ptr [si+1eH],0000H
  601.  
  602.  bufferInts = wsPtr->audioBufferInts;           // interrupts per dma buffer (def=0, two per buffer)
  603.  0308  8b 47 16          L31             mov     ax,[bx+16H]
  604.  030b  89 46 fc                          mov     [bp-4H],ax
  605.  
  606.  if (bufferInts < 2) bufferInts = 2;            // at least two (must be a power of 2)
  607.  
  608. // !!! (29-Sep-99)
  609. //bufferInts = 8;
  610.  
  611.  030e  3d 02 00                          cmp     ax,0002H
  612.  0311  73 05                             jae     L32
  613.  0313  c7 46 fc 02 00                    mov     word ptr [bp-4H],0002H
  614.  
  615.  tbps = waveConfigPtr->bitsPerSample;
  616.  tBytesPS = tbps/8;
  617.  0318  8a 45 04          L32             mov     al,[di+4H]
  618.  031b  30 e4                             xor     ah,ah
  619.  
  620.  tIs16 = tBytesPS >> 1;
  621.  
  622.  031d  c1 e8 04                          shr     ax,04H
  623.  0320  89 46 fe                          mov     [bp-2H],ax
  624.  
  625.  tch  = waveConfigPtr->channels;
  626.  tIsST = tch >> 1;
  627.  
  628.  // set clock select bits, using first SRT with sample rate >= requested rate
  629.  // eg, if req=44000 then uses 44100 (if req=2000 then uses 5512)
  630.  // this was done in a call to _vset_clock_info(ULONG freq)
  631.  
  632.  0323  8a 45 05                          mov     al,[di+5H]
  633.  0326  30 e4                             xor     ah,ah
  634.  
  635.  for (i=0; i < SRT_COUNT; i++) {
  636.  0328  31 d2                             xor     dx,dx
  637.  032a  d1 e8                             shr     ax,1
  638.  032c  31 db                             xor     bx,bx
  639.  032e  89 46 fa                          mov     [bp-6H],ax
  640.  0331  31 c0                             xor     ax,ax
  641.  
  642.     if (srt[i].sampleRate >= waveConfigPtr->sampleRate) {
  643.  0333  8b 8f 00 00       L33             mov     cx,[bx+_srt]
  644.  0337  3b 0d                             cmp     cx,[di]
  645.  0339  72 09                             jb      L34
  646.  
  647.        waPtr->clockSelectData = srt[i].clockSelect;
  648.  033b  8a 87 02 00                       mov     al,[bx+_srt+2H]
  649.  033f  88 44 08                          mov     [si+8H],al
  650.  
  651.        break; // out of for
  652.     }
  653.  0342  eb 1b                             jmp     L35
  654.  
  655.     waPtr->clockSelectData = srt[SRT_COUNT-1].clockSelect;  // requested is > last srt, so use last
  656.  0344  8a 0e 36 00       L34             mov     cl,_srt+36H
  657.  
  658.  }
  659.  
  660.  // set up WAVEAUDIO.formatData, set silence data, set mono/stereo
  661.  
  662.  0348  83 c3 04                          add     bx,0004H
  663.  034b  83 c2 01                          add     dx,0001H
  664.  034e  15 00 00                          adc     ax,0000H
  665.  0351  88 4c 08                          mov     [si+8H],cl
  666.  0354  85 c0                             test    ax,ax
  667.  0356  72 db                             jb      L33
  668.  0358  75 05                             jne     L35
  669.  035a  83 fa 0e                          cmp     dx,000eH
  670.  035d  72 d4                             jb      L33
  671.  
  672.  switch (waveConfigPtr->dataType) {
  673.  case DATATYPE_WAVEFORM:
  674.  case PCM:
  675.  035f  8b 45 06          L35             mov     ax,[di+6H]
  676.  0362  3d 05 00                          cmp     ax,0005H
  677.  0365  72 1a                             jb      L37
  678.  0367  3d 06 00                          cmp     ax,0006H
  679.  036a  76 42                             jbe     L40
  680.  036c  3d 01 01                          cmp     ax,0101H
  681.  036f  72 09                             jb      L36
  682.  0371  76 46                             jbe     L41
  683.  0373  3d 02 01                          cmp     ax,0102H
  684.  0376  74 36                             je      L40
  685.  0378  eb 48                             jmp     L42
  686.  037a  3d 07 00          L36             cmp     ax,0007H
  687.  037d  74 3a                             je      L41
  688.  037f  eb 41                             jmp     L42
  689.  0381  3d 01 00          L37             cmp     ax,0001H
  690.  0384  72 3c                             jb      L42
  691.  0386  3d 02 00                          cmp     ax,0002H
  692.  0389  76 07                             jbe     L38
  693.  038b  3d 03 00                          cmp     ax,0003H
  694.  038e  74 29                             je      L41
  695.  0390  eb 30                             jmp     L42
  696.  
  697.     if (tIs16) {
  698.  0392  83 7e fe 00       L38             cmp     word ptr [bp-2H],0000H
  699.  0396  74 0b                             je      L39
  700.  
  701.        waPtr->formatData = FORMAT_BIT0;
  702.  0398  c6 44 09 40                       mov     byte ptr [si+9H],40H
  703.  
  704.        waveConfigPtr->silence = 0x0000;
  705.     }
  706.  039c  c7 45 02 00 00                    mov     word ptr [di+2H],0000H
  707.  
  708.     else {
  709.  03a1  eb 1f                             jmp     L42
  710.  
  711.        waPtr->formatData = 0;
  712.  03a3  c6 44 09 00       L39             mov     byte ptr [si+9H],00H
  713.  
  714.        waveConfigPtr->silence = 0x8080;
  715.  03a7  c7 45 02 80 80                    mov     word ptr [di+2H],8080H
  716.  
  717.     }
  718.     break;
  719.  
  720.  case DATATYPE_ALAW:
  721.  case DATATYPE_RIFF_ALAW:
  722.  case A_LAW:
  723.  03ac  eb 14                             jmp     L42
  724.  
  725.     waPtr->formatData = FORMAT_BIT0 | CL_BIT;
  726.  03ae  c6 44 09 60       L40             mov     byte ptr [si+9H],60H
  727.  
  728.     waveConfigPtr->silence = 0x5555;
  729.  03b2  c7 45 02 55 55                    mov     word ptr [di+2H],5555H
  730.  
  731.     break;
  732.  
  733.  case DATATYPE_MULAW:
  734.  case DATATYPE_RIFF_MULAW:
  735.  case MU_LAW:
  736.  03b7  eb 09                             jmp     L42
  737.  
  738.     waPtr->formatData = CL_BIT;
  739.  03b9  c6 44 09 20       L41             mov     byte ptr [si+9H],20H
  740.  
  741.     waveConfigPtr->silence = 0x7F7F;
  742.     break;
  743.  }
  744.  
  745.  03bd  c7 45 02 7f 7f                    mov     word ptr [di+2H],7f7fH
  746.  
  747.  if (tIsST) waPtr->formatData = waPtr->formatData | STEREO_BIT;  // set stereo bit
  748.  
  749.  03c2  83 7e fa 00       L42             cmp     word ptr [bp-6H],0000H
  750.  03c6  74 04                             je      L43
  751.  03c8  80 4c 09 10                       or      byte ptr [si+9H],10H
  752.  03cc  8b 5e fc          L43             mov     bx,[bp-4H]
  753.  
  754.  count = waPtr->ab.bufferSize/bufferInts;// bytes per interrupt
  755.  waveConfigPtr->bytesPerIRQ = count;    // grab it while it's still bytes
  756.  03cf  8b 44 1c                          mov     ax,[si+1cH]
  757.  03d2  8b 54 1e                          mov     dx,[si+1eH]
  758.  03d5  31 c9                             xor     cx,cx
  759.  03d7  e8 00 00                          call    __U4D
  760.  03da  89 d3                             mov     bx,dx
  761.  03dc  89 55 0e                          mov     [di+0eH],dx
  762.  
  763.  03df  8b 56 fe                          mov     dx,[bp-2H]
  764.  
  765.  if (tIs16) count = count >> 1;         // if 16-bit then half as many as that in samples
  766.  03e2  89 45 0c                          mov     [di+0cH],ax
  767.  03e5  85 d2                             test    dx,dx
  768.  03e7  74 04                             je      L44
  769.  03e9  d1 eb                             shr     bx,1
  770.  03eb  d1 d8                             rcr     ax,1
  771.  
  772.  if (tIsST) count = count >> 1;         // if stereo then half as many as that in samples again
  773.  03ed  83 7e fa 00       L44             cmp     word ptr [bp-6H],0000H
  774.  03f1  74 04                             je      L45
  775.  03f3  d1 eb                             shr     bx,1
  776.  03f5  d1 d8                             rcr     ax,1
  777.  
  778.  waPtr->countData = count-1;            // samples per interrupt
  779.  
  780. // !!!
  781.  03f7  89 c2             L45             mov     dx,ax
  782.  03f9  4a                                dec     dx
  783.  03fa  89 54 0a                          mov     [si+0aH],dx
  784.  
  785. if (gCLflags & FLAGS_CL_DDPRINT) ddprintf("@waConfigDev:count=%lxh, bytes/IRQ=%lxh\n",count,waveConfigPtr->bytesPerIRQ);
  786.  
  787.  // calc PCM consume rate
  788.  // The consume rate is the number of bytes consumed by this data format per second, based on:
  789.  //    rate = sampleRate * bps/8 * channels
  790.  // this is returned to the WAVESTREAM and used to calculate stream time
  791.  
  792.  consumeRate = waveConfigPtr->sampleRate;
  793.  03fd  f6 06 01 00 40                    test    byte ptr _gCLflags+1H,40H
  794.  0402  74 14                             je      L46
  795.  0404  8b 55 0e                          mov     dx,[di+0eH]
  796.  0407  52                                push    dx
  797.  0408  8b 4d 0c                          mov     cx,[di+0cH]
  798.  040b  51                                push    cx
  799.  040c  53                                push    bx
  800.  040d  50                                push    ax
  801.  040e  1e                                push    ds
  802.  040f  68 4c 00                          push    offset L51
  803.  0412  e8 00 00                          call    _ddprintf
  804.  0415  83 c4 0c                          add     sp,000cH
  805.  
  806.  0418  8b 4e fe          L46             mov     cx,[bp-2H]
  807.  
  808.  if (tIs16) consumeRate = consumeRate + consumeRate;
  809.  041b  8b 1d                             mov     bx,[di]
  810.  041d  31 c0                             xor     ax,ax
  811.  041f  89 da                             mov     dx,bx
  812.  0421  85 c9                             test    cx,cx
  813.  0423  74 04                             je      L47
  814.  0425  01 da                             add     dx,bx
  815.  0427  11 c0                             adc     ax,ax
  816.  
  817.  if (tIsST) consumeRate = consumeRate + consumeRate;
  818.  0429  83 7e fa 00       L47             cmp     word ptr [bp-6H],0000H
  819.  042d  74 04                             je      L48
  820.  042f  01 d2                             add     dx,dx
  821.  0431  11 c0                             adc     ax,ax
  822.  
  823.  waveConfigPtr->consumeRate = consumeRate;
  824.  
  825.  // reinit dma
  826.  // (dmaType has extra meaning: typeFdma is at bit8, so add it in (set in original dmaInit())
  827.  
  828.  0433  89 55 08          L48             mov     [di+8H],dx
  829.  0436  89 45 0a                          mov     [di+0aH],ax
  830.  
  831.  dmaType = waPtr->ab.dmaCh.type | ((waPtr->ab.dmaCh.chInfo.typeFdma & 1) << 8);
  832.  0439  8a 64 49                          mov     ah,[si+49H]
  833.  043c  80 e4 01                          and     ah,01H
  834.  043f  8b 54 30                          mov     dx,[si+30H]
  835.  0442  30 c0                             xor     al,al
  836.  
  837.  dmaInit(waPtr->ab.dmaCh.ch, dmaType, &waPtr->ab);
  838.  
  839.  return;
  840.  0444  8d 5c 0c                          lea     bx,[si+0cH]
  841.  0447  09 c2                             or      dx,ax
  842.  0449  8b 44 2e                          mov     ax,[si+2eH]
  843.  044c  e8 00 00                          call    dmaInit_
  844.  
  845. }
  846.  
  847.  
  848. // ---------------
  849. // in: n/a (maybe)
  850. //out: 1 always
  851. //nts: not used (use Stop stream instead)
  852.  
  853.  044f  89 ec                             mov     sp,bp
  854.  0451  5d                                pop     bp
  855.  0452  5f                                pop     di
  856.  0453  5e                                pop     si
  857.  0454  5a                                pop     dx
  858.  0455  59                                pop     cx
  859.  0456  5b                                pop     bx
  860.  0457  c3                                ret     
  861.  
  862. USHORT waPause(VOID) {
  863.  
  864.  return 1;
  865. }
  866.  
  867.  
  868. // ---------------
  869. // in: n/a (maybe)
  870. //out: 1 always
  871. //nts: not used (use Start stream instead)
  872.  
  873. USHORT waResume(VOID) {
  874.  
  875.  return 1;
  876. }
  877.  
  878.  
  879. #pragma code_seg ("_INITTEXT");
  880. #pragma data_seg ("_INITDATA","ENDDS");
  881.  
  882.  
  883. // -----------------------------
  884. // in: dma channel = dma channel
  885. //     waPtr -> WAVEAUDIO structure for this object
  886. //out: 0 if okay, else error
  887. //nts: called by wpInit() and wrInit(), each of which have their own, single WAVEAUDIO structure
  888. //     and then only once, at driver init
  889. //     sets up:
  890. //      1. audioBuffer allocation and init
  891. //      2. dma init
  892. //     on entry, waPtr->flags:
  893. //      FLAGS_WAVEAUDIO_FULLDUPLEX  1   // can do full-duplex (has separate DMA for play/rec)
  894. //      FLAGS_WAVEAUDIO_DMA16       2   // dma channel is 16-bit (and waPtr->dmaPtr->ch itself)
  895. //      FLAGS_WAVEAUDIO_FTYPEDMA    4   // hardware support demand-mode dma
  896. //     passing dmaChannel to simplify
  897. //     was _vSetup()
  898.  
  899.  0458                    waPause_:
  900.  0458  b8 01 00          waResume_       mov     ax,0001H
  901.  045b  c3                                ret     
  902.  
  903. No disassembly errors
  904.  
  905. List of external symbols
  906.  
  907. Symbol
  908. ----------------
  909. _war             00000029
  910. _wap             00000048
  911. _sampleRates     000000e9 000000c8 000000be
  912. _gCLflags        000003ff 000002a4 00000107
  913. _ddprintf        00000413 000002c0 00000117
  914. _waveSubtypes    000001c1
  915. _aLaw            000001e4
  916. _muLaw           00000201
  917. _srt             00000346 0000033d 00000335
  918. __U4D            000003d8
  919. dmaInit_         0000044d
  920. ------------------------------------------------------------
  921.  
  922. Segment: CONST  WORD   00000075 bytes  
  923.  0000  77 61 44 65 76 43 61 70 L49             - waDevCap
  924.  0008  73 3a 20 75 73 69 6e 67                 - s: using
  925.  0010  20 42 45 53 54 46 49 54                 -  BESTFIT
  926.  0018  20 73 61 6d 70 6c 65 52                 -  sampleR
  927.  0020  61 74 65 0a 00 00                       - ate...
  928.  0026  40 77 61 44 65 76 43 61 L50             - @waDevCa
  929.  002e  70 73 3a 20 64 65 76 43                 - ps: devC
  930.  0036  61 70 73 50 74 72 2d 3e                 - apsPtr->
  931.  003e  75 6c 46 6c 61 67 73 3d                 - ulFlags=
  932.  0046  25 6c 78 0a 00 00                       - %lx...
  933.  004c  40 77 61 43 6f 6e 66 69 L51             - @waConfi
  934.  0054  67 44 65 76 3a 63 6f 75                 - gDev:cou
  935.  005c  6e 74 3d 25 6c 78 68 2c                 - nt=%lxh,
  936.  0064  20 62 79 74 65 73 2f 49                 -  bytes/I
  937.  006c  52 51 3d 25 6c 78 68 0a                 - RQ=%lxh.
  938.  0074  00                                      - .
  939.  
  940. No disassembly errors
  941.  
  942. ------------------------------------------------------------
  943.  
  944. Segment: _DATA  WORD   00000080 bytes  
  945.  0000  88 15 01 00 d7 19 0f 00 _srt            - ........
  946.  0008  40 1f 00 00 80 25 0e 00                 - @....%..
  947.  0010  11 2b 03 00 80 3e 02 00                 - .+...>..
  948.  0018  d4 49 05 00 22 56 07 00                 - .I.."V..
  949.  0020  24 6b 04 00 00 7d 06 00                 - $k...}..
  950.  0028  33 81 0d 00 a8 93 09 00                 - 3.......
  951.  0030  44 ac 0b 00 80 bb 0c 00                 - D.......
  952.  0038  01 00 02 00 03 00 04 00 _waveSubtypes   - ........
  953.  0040  05 00 06 00 07 00 08 00                 - ........
  954.  0048  09 00 0a 00 0b 00 0c 00                 - ........
  955.  0050  0d 00 0e 00 0f 00 10 00                 - ........
  956.  0058  06 00 02 00 07 00 03 00 _aLaw           - ........
  957.  0060  08 00 04 00 05 00 01 00                 - ........
  958.  0068  06 00 02 00 07 00 03 00 _muLaw          - ........
  959.  0070  08 00 04 00 05 00 01 00                 - ........
  960.  0078  11 2b 22 56 44 ac 40 1f _sampleRates    - .+"VD.@.
  961.  
  962. No disassembly errors
  963.  
  964. ------------------------------------------------------------
  965.  
  966. Segment: _INITTEXT  PARA   0000005f bytes  
  967.  
  968. USHORT waSetup(USHORT dmaChannel, WAVEAUDIO *waPtr) {
  969.  
  970.  USHORT rc = 0;
  971.  0000  53                waSetup_        push    bx
  972.  0001  51                                push    cx
  973.  0002  56                                push    si
  974.  0003  57                                push    di
  975.  0004  55                                push    bp
  976.  0005  89 e5                             mov     bp,sp
  977.  0007  83 ec 02                          sub     sp,0002H
  978.  000a  89 c7                             mov     di,ax
  979.  000c  89 d6                             mov     si,dx
  980.  
  981.  USHORT typeDMA = DMA_TYPE_ISA; // will be OR'ed with DMA_TYPE_PLAY(dma-read)/CAPTURE(dma-write)
  982.  ULONG  sizeDMA = DMA_BUFFER_SIZE;  // physical size, will be xxKB always (after testing)
  983.  ULONG  sizePage = 0; // 0 because...dunno, not used I suppose
  984.  
  985.  000e  ba 08 00                          mov     dx,0008H
  986.  
  987.  rc = abInit(sizeDMA, sizePage, dmaChannel, &waPtr->ab);
  988.  0011  8d 44 0c                          lea     ax,[si+0cH]
  989.  0014  31 db                             xor     bx,bx
  990.  0016  31 c9                             xor     cx,cx
  991.  0018  89 56 fe                          mov     [bp-2H],dx
  992.  001b  50                                push    ax
  993.  001c  b8 00 f0                          mov     ax,0f000H
  994.  001f  57                                push    di
  995.  0020  31 d2                             xor     dx,dx
  996.  0022  e8 00 00                          call    abInit_
  997.  0025  89 c2                             mov     dx,ax
  998.  
  999.  if (rc) goto ExitNow;
  1000.  
  1001.  0027  85 c0                             test    ax,ax
  1002.  0029  75 2a                             jne     L54
  1003.  
  1004.  if (waPtr->devType == AUDIOHW_WAVE_PLAY) {
  1005.     typeDMA = typeDMA | DMA_TYPE_PLAY;
  1006.  }
  1007.  else {
  1008.  002b  83 7c 02 11                       cmp     word ptr [si+2H],0011H
  1009.  002f  74 05                             je      L52
  1010.  
  1011.     typeDMA = typeDMA | DMA_TYPE_CAPTURE;
  1012.  }
  1013.  
  1014.  0031  c7 46 fe 09 00                    mov     word ptr [bp-2H],0009H
  1015.  
  1016.  if (waPtr->flags & FLAGS_WAVEAUDIO_FTYPEDMA) {
  1017.  0036  f6 04 04          L52             test    byte ptr [si],04H
  1018.  0039  74 04                             je      L53
  1019.  
  1020.     typeDMA = typeDMA | DMA_TYPE_FTYPE;
  1021.  003b  80 4e ff 01                       or      byte ptr [bp-1H],01H
  1022.  
  1023.  }
  1024.  
  1025.  003f  8b 56 fe          L53             mov     dx,[bp-2H]
  1026.  
  1027.  rc = dmaInit(dmaChannel, typeDMA, &waPtr->ab);
  1028.  0042  8d 5c 0c                          lea     bx,[si+0cH]
  1029.  0045  89 f8                             mov     ax,di
  1030.  0047  e8 00 00                          call    dmaInit_
  1031.  004a  89 c2                             mov     dx,ax
  1032.  
  1033.  if (rc) goto ExitNow;
  1034.  
  1035.  004c  85 c0                             test    ax,ax
  1036.  004e  75 05                             jne     L54
  1037.  
  1038.  waPtr->irqHandlerPtr = (NPFN)irqHandler;  // assign near function pointer to IRQ handler (always CS:offset)
  1039.  
  1040. ExitNow:
  1041.  return rc;
  1042.  0050  c7 44 06 00 00                    mov     word ptr [si+6H],offset irqHandler_
  1043.  
  1044. }
  1045.  
  1046.  
  1047.  0055  89 d0             L54             mov     ax,dx
  1048.  0057  89 ec                             mov     sp,bp
  1049.  0059  5d                                pop     bp
  1050.  005a  5f                                pop     di
  1051.  005b  5e                                pop     si
  1052.  005c  59                                pop     cx
  1053.  005d  5b                                pop     bx
  1054.  005e  c3                                ret     
  1055.  
  1056. No disassembly errors
  1057.  
  1058. List of external symbols
  1059.  
  1060. Symbol
  1061. ----------------
  1062. abInit_          00000023
  1063. dmaInit_         00000048
  1064. irqHandler_      00000053
  1065. ------------------------------------------------------------
  1066. List of public symbols
  1067.  
  1068. SYMBOL          GROUP           SEGMENT          ADDRESS
  1069. ---------------------------------------------------------
  1070. _aLaw           DGROUP          _DATA            00000058
  1071. _muLaw          DGROUP          _DATA            00000068
  1072. _sampleRates    DGROUP          _DATA            00000078
  1073. _srt            DGROUP          _DATA            00000000
  1074. _waveSubtypes   DGROUP          _DATA            00000038
  1075. waConfigDev_                    _TEXT            000002d0
  1076. waDevCaps_                      _TEXT            00000000
  1077. waPause_                        _TEXT            00000458
  1078. waResume_                       _TEXT            00000458
  1079. waSetup_                        _INITTEXT        00000000
  1080.  
  1081. ------------------------------------------------------------
  1082.  
  1083.