home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / pas.asm < prev    next >
Assembly Source File  |  1994-08-06  |  18KB  |  749 lines

  1. ;*    PAS.ASM
  2. ;*
  3. ;* Pro Audio Spectrum Sound Device, v1.10
  4. ;*
  5. ;* Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6. ;*
  7. ;* This file is part of the MIDAS Sound System, and may only be
  8. ;* used, modified and distributed under the terms of the MIDAS
  9. ;* Sound System license, LICENSE.TXT. By continuing to use,
  10. ;* modify or distribute this file you indicate that you have
  11. ;* read the license and understand and accept it fully.
  12. ;*
  13.  
  14. ;* NOTE! A lot of this code is ripped more or less directly from the PAS
  15. ;* SDK and might therefore seem messy.
  16. ;* I really do not understand some parts of this code... Perhaps I'll clear
  17. ;* it up some day when I have time.
  18. ;* (PK)
  19.  
  20.  
  21.  
  22. IDEAL
  23. P386
  24. JUMPS
  25.  
  26. INCLUDE "pas.inc"
  27. INCLUDE "lang.inc"
  28. INCLUDE "errors.inc"
  29. INCLUDE "sdevice.inc"
  30. INCLUDE "dsm.inc"
  31. INCLUDE "dma.inc"
  32.  
  33.  
  34.  
  35. ;/***************************************************************************\
  36. ;*       enum pasFunctIDs
  37. ;*       ----------------
  38. ;* Description:  ID numbers for PAS Sound Device functions
  39. ;\***************************************************************************/
  40.  
  41. enum    pasFunctIDs \
  42.         ID_pasDetect = ID_pas, \
  43.         ID_pasInit, \
  44.         ID_pasClose
  45.  
  46.  
  47.  
  48. DATASEG
  49.  
  50.  
  51. pasVersion    DB    ?        ; card version
  52. pasSpeed    DW    ?        ; output rate value
  53. pasRate     DW    ?        ; actual output rate
  54. pasMode     DW    ?        ; output mode
  55.  
  56.  
  57.  
  58.  
  59. IDATASEG
  60.  
  61.  
  62. GLOBAL    PAS : SoundDevice
  63.  
  64. PAS        SoundDevice    < \
  65.         0, 388h, 15, 5, sdUnInitialized, \
  66.     sdStereo or sdMono or sd16bit or sd8bit or sdNormalQ, \
  67.     far ptr pasID, \
  68.     far ptr pasDetect, \
  69.     far ptr pasInit, \
  70.     far ptr pasClose, \
  71.     far ptr dsmGetMixRate, \
  72.     far ptr dsmGetMode, \
  73.     far ptr dsmOpenChannels, \
  74.     far ptr dsmCloseChannels, \
  75.     far ptr dsmClearChannels, \
  76.     far ptr dsmMute, \
  77.     far ptr dsmPause, \
  78.     far ptr dsmSetMasterVolume, \
  79.     far ptr dsmPlaySound, \
  80.     far ptr dsmStopSound, \
  81.     far ptr dsmSetRate, \
  82.     far ptr dsmGetRate, \
  83.     far ptr dsmSetVolume, \
  84.     far ptr dsmSetInstrument, \
  85.     far ptr dsmSetPosition, \
  86.     far ptr dsmGetPosition, \
  87.     far ptr dsmSetPanning, \
  88.     far ptr dsmGetPanning, \
  89.     far ptr dsmMuteChannel, \
  90.     far ptr dsmAddInstrument, \
  91.     far ptr dsmRemInstrument, \
  92.     far ptr dsmSetUpdRate, \
  93.     far ptr dsmPlay >
  94.  
  95.  
  96. pasID   db      "Pro Audio Spectrum series Sound Device v1.10",0
  97.  
  98.  
  99.  
  100. _mvHWVersionBits    dw    -1    ; holds the product feature bits
  101. _mvTranslateCode    dw    0    ; I/O base xor default_base
  102.  
  103. VERSION_PAS        equ    0    ; Pro Audio Spectrum
  104. VERSION_PASPLUS     equ    1    ; Pro Audio Plus card
  105. VERSION_PAS16        equ    2    ; Pro Audio 16 card
  106. VERSION_CDPC        equ    3    ; CDPC card & unit
  107.  
  108. ;
  109. ; The following equates build up a mask of bits that we do wish to keep
  110. ; when comparing feature bits. The zero bits can be ignored, whereas, the
  111. ; the 1 bits must match.
  112. ;
  113.  
  114. PASdocare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  115. PASPLUSdocare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  116. PAS16docare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  117. CDPCdocare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  118.  
  119. ;
  120. LABEL    ProductIDTable    WORD
  121.     dw    PRODUCT_PROAUDIO and PASdocare
  122.     dw    PRODUCT_PROPLUS  and PASPLUSdocare
  123.     dw    PRODUCT_PRO16     and PAS16docare
  124.     dw    PRODUCT_CDPC     and CDPCdocare
  125.     dw    -1
  126. ;
  127. LABEL    DoCareBits    WORD
  128.     dw    PASdocare
  129.     dw    PASPLUSdocare
  130.     dw    PAS16docare
  131.     dw    CDPCdocare
  132.     dw    -1                ; table terminator
  133.  
  134. mvhwShadowPointer    dd    0      ; points to the start of the data table
  135.  
  136. ;
  137. ; These variables mirror the hardware state
  138. ;
  139. HardwareShadowTable    db    (size MVState) dup (0)
  140.  
  141. ; ---
  142.  
  143. CODESEG
  144.  
  145.  
  146.  
  147. PUBLIC    pasDetect
  148. PUBLIC    pasInit
  149. PUBLIC    pasClose
  150.  
  151.  
  152.  
  153.  
  154. PROC    pasSearchHW    FAR
  155. USES    si,di
  156.  
  157. ;
  158. ; calculate the translation code
  159. ;
  160.     mov    [PAS.port],di
  161.  
  162.     xor    di,DEFAULT_BASE     ; di holds the translation code
  163.  
  164.     mov    ax,0BC00H        ; make sure MVSOUND.SYS is loaded
  165.     mov    bx,'??'                 ; this is our way of knowing if the
  166.     xor    cx,cx            ; hardware is actually present.
  167.     xor    dx,dx
  168.     int    2fh            ; get the ID pattern
  169.     xor    bx,cx            ; build the result
  170.     xor    bx,dx
  171.     cmp    bx,'MV'                 ; if not here, exit...
  172.     jne    @@bad
  173.  
  174. ;
  175. ; get the MVSOUND.SYS specified DMA and IRQ channel
  176. ;
  177.     mov    ax,0bc04h        ; get the DMA and IRQ numbers
  178.     int    2fh
  179.     mov    [PAS.DMA],bl        ; save the correct DMA & IRQ
  180.     mov    [PAS.IRQ],cl
  181.  
  182. ;
  183. ; grab the version # in the interrupt mask. The top few bits hold the version #
  184. ;
  185.     mov    dx,INTRCTLR        ; board ID is in MSB 3 bits
  186.     xor    dx,di            ; adjust to other address
  187.     in    al,dx
  188.     cmp    al,-1            ; bus float meaning not present?
  189.     je    @@bad            ; yes, there is no card here
  190.  
  191.     mov    ah,al            ; save an original copy
  192.     xor    al,fICrevbits        ; the top bits wont change
  193.  
  194.     out    dx,al            ; send out the inverted bits
  195.     jmp    $+2
  196.     jmp    $+2
  197.     in    al,dx            ; get it back...
  198.  
  199.     cmp    al,ah            ; both should match now...
  200.     xchg    al,ah            ; (restore without touching the flags)
  201.     out    dx,al
  202.  
  203.     jnz    @@bad            ; we have a bad board
  204.  
  205.     and    ax,fICrevbits        ; isolate the ID bits & clear AH
  206.     mov    cl,fICrevshr        ; shift the bits into a meaningful
  207.     shr    al,cl            ; position (least signficant bits)
  208.     mov    si,ax            ; save the version #
  209. ;
  210. ; We do have hardware! Load the product bit definitions
  211. ;
  212.     sub    bx,bx
  213.     mov    cx,bMVSCSI        ; setup bx:cx for the original PAS
  214.  
  215.     or    al,al            ; is this the first version of h/w?
  216.     jz    @@hwdone        ; yes, simple exit will do.
  217.  
  218.  
  219. ; All second generation Pro Audio cards use the MV101 and have SB emulation.
  220. ;
  221.     or    cx,bMVSBEMUL+bMV101    ; force SB emulation
  222. ;
  223. ; determine if the enhanced SCSI interface is present
  224. ;
  225.     mov    dx,ENHANCEDSCSI     ; test for SCSI mod (U48)
  226.     xor    dx,di            ; modify via the translate code
  227.  
  228.     out    dx,al            ; strobe
  229.     jmp    $+2            ; I/O bus delay
  230.     in    al,dx            ; get the bit
  231.  
  232.     and    al,1            ; bit0==1 means old SCSI PAL
  233.     cmp    al,1            ; reverse sense
  234.     sbb    ax,ax            ; ax = ffff if enhanced SCSI
  235.     and    ax,bMVENHSCSI        ; save the bit
  236.     or    cx,ax            ; merge it in
  237. ;
  238. ; determine AT/PS2, CDPC slave mode
  239. ;
  240.     mov    dx,MASTERMODRD        ; check for the CDPC
  241.     xor    dx,di            ; modify via the translate code
  242.  
  243.     in    al,dx
  244.     test    al,bMMRDatps2        ; AT(1) or PS2(0)
  245.     jnz    @@1
  246.     or    cx,bMVPS2
  247.     ;
  248.     @@1:
  249.     test    al,bMMRDmsmd        ; Master(0) or Slave(1)
  250.     jz    @@2
  251.     or    cx,bMVSLAVE
  252.     ;
  253.     @@2:
  254.     push    cx            ; move the revision bits
  255.  
  256.     mov    dx,MASTERCHIPR
  257.     xor    dx,di
  258.  
  259.     ERRIF    bMV101_REV-(000Fh SHL 11)
  260.  
  261.     in    al,dx            ; get the low 4 bits of the chip rev
  262.     and    ax,000Fh        ; into ah
  263.     mov    cl,11            ; FROM 0000 0000 0000 1111b
  264.     shl    ax,cl            ; TO   0111 1000 0000 0000b
  265.  
  266.     pop    cx
  267.     or    cx,ax            ; merge in the bits
  268. ;
  269. ; determine the CDROM drive type, FM chip, 8/16 bit DAC, and mixer
  270. ;
  271.     mov    dx,SLAVEMODRD        ; check for the CDPC
  272.     xor    dx,di            ; modify via the translate code
  273.     in    al,dx
  274.  
  275.     test    al,bSMRDdactyp        ; 16 bit DAC?
  276.     jz    @@3            ; no, its an 8 bit DAC
  277.     or    cx,bMVDAC16        ; its a 16 bit DAC
  278.     ;
  279.     @@3:
  280.     test    al,bSMRDfmtyp        ; OPL3 chip?
  281.     jz    @@4            ; no, so it's the PAS16 card
  282.     or    cx,bMVOPL3        ; is an OPL3
  283.     ;
  284.     @@4:
  285.     mov    dx,cx            ; inference check for new mixer
  286.     and    dx,bMVSLAVE+bMVDAC16    ; Slave & 16 bit dac is the CDPC
  287.     cmp    dx,bMVDAC16        ; 16 bit DAC on master?
  288.     jnz    @@5            ; no, it's the CDPC with Nation mixer
  289.     or    cx,bMVA508
  290.     ;
  291.     @@5:
  292.     and    al,bSMRDdrvtyp        ; isolate the CDROM drive type
  293.     cmp    al,2            ; Sony 535 interface?
  294.     jnz    @@6            ; no, continue on...
  295.     and    cx,NOT (bMVSCSI+bMVENHSCSI) ; yes, flush the SCSI bits
  296.     or    cx,bMVSONY            ; set the 535 bit
  297.     ;
  298.     @@6:
  299. ;
  300. ; determine if MPU-401 emulation is active
  301. ;
  302.     mov    dx,COMPATREGE        ; compatibility register
  303.     xor    dx,di            ; modify via translate code
  304.     in    al,dx
  305.     test    al,cpMPUEmulation
  306.     jz    @@7
  307.     or    cx,bMVMPUEMUL
  308.     ;
  309.     @@7:
  310. ;
  311. @@hwdone:
  312. ;
  313. ; loop on a table search to find identify the board
  314. ;
  315.     push    bx            ; save this high bits
  316.     mov    bx,-2
  317.     ;
  318.     @@lp:
  319.     add    bx,2
  320.     cmp    [ProductIDTable+bx],-1    ; at the end of the table?
  321.     jz    @@badhw         ; yes, we can't identify this board
  322.     mov    dx,cx            ; dx holds the product bits
  323.     and    dx,[DoCareBits+bx]    ; keep the bits we care about
  324.     cmp    dx,[ProductIDTable+bx]    ; do these bits match a product?
  325.     jne    @@lp            ; no, keep looking
  326.  
  327.     mov    dx,bx
  328.     shr    dx,1            ; make word index a byte index
  329.     pop    bx
  330.  
  331.     mov    [_mvTranslateCode],di    ; save the translation code (ie. port)
  332.  
  333.     mov    ax,si            ; load the h/w version #
  334.     sub    ah,ah            ; for our purposes, we will return SCSI
  335.     xchg    ah,al            ; into ah
  336.     clc                ; The board was identified !
  337.  
  338.     mov    [_mvHWVersionBits],cx    ; save the good bits
  339.  
  340.     jmp    @@done
  341. ;
  342. @@badhw:
  343.     pop    bx            ; flush the stack
  344.     mov    ax,-2
  345.     cwd
  346.     stc
  347.     jmp    @@done
  348. ;
  349. @@bad:
  350.     mov    ax,-1            ; we got here due to a bad board
  351.     cwd
  352.     stc
  353. ;
  354. @@done:
  355.     ret
  356. ENDP
  357.  
  358.  
  359.  
  360.  
  361. ;/***************************************************************************\
  362. ;*
  363. ;* Function:    int pasDetect(int *result);
  364. ;*
  365. ;* Description: Detects Pro Audio Spectrum soundcard
  366. ;*
  367. ;* Returns:     MIDAS error code.
  368. ;*              1 stored to *result if PAS was detected, 0 if not.
  369. ;*
  370. ;\***************************************************************************/
  371.  
  372. PROC    pasDetect       FAR     result : dword
  373.  
  374.     ; search the default address
  375.  
  376.     mov    di,DEFAULT_BASE     ; try the first address
  377.     call    pasSearchHW
  378.     cmp    dx,-1            ; found?
  379.     jnz    @@found         ; yes, exit now...
  380.  
  381.     ; search the first alternate address
  382.  
  383.     mov    di,ALT_BASE_1        ; try the first alternate
  384.     call    pasSearchHW
  385.     cmp    dx,-1            ; found?
  386.     jnz    @@found         ; yes, exit now...
  387.  
  388.     ; search the second alternate address
  389.  
  390.     mov    di,ALT_BASE_2        ; try the second alternate
  391.     call    pasSearchHW
  392.     cmp    dx,-1            ; found?
  393.     jnz    @@found         ; yes, exit now...
  394.  
  395.     ; search the third, or user requested alternate address
  396.  
  397.     mov    di,ALT_BASE_3        ; try the third alternate
  398.     call    pasSearchHW        ; pass the third A, or user I/O
  399.  
  400. @@found:
  401.         les     bx,[result]             ; point es:bx to result variable
  402.  
  403.         or      dx,dx                   ; if dx:ax negative, no card found
  404.         js      @@nopas
  405.  
  406.     mov    [pasVersion],ah     ; store the PAS version
  407.         mov     [word es:bx],1          ; PAS detected succesfully
  408.         jmp     @@ok
  409.  
  410. @@nopas:
  411.         mov     [word es:bx],0          ; no PAS found
  412.  
  413. @@ok:
  414.         xor     ax,ax                   ; success
  415.  
  416.     ret
  417. ENDP
  418.  
  419.  
  420.  
  421.  
  422. ;/***************************************************************************\
  423. ;*
  424. ;* Function:    int pasInit(ushort mixRate, ushort mode);
  425. ;*
  426. ;* Description: Initializes Pro Audio Spectrum
  427. ;*
  428. ;* Input:    mixRate     mixing rate
  429. ;*        mode        output mode (see enum sdMode)
  430. ;*
  431. ;* Returns:     MIDAS error code
  432. ;*
  433. ;\***************************************************************************/
  434.  
  435. PROC    pasInit     FAR    mixRate : word, mode : word
  436. USES    si,di
  437.  
  438.     mov    [pasMode],0
  439.  
  440.     test    [mode],sd8bit        ; force 8-bit?
  441.     jnz    @@8b
  442.     or    [pasMode],sd16bit    ; if not, use 16 bits
  443.     jmp    @@bit
  444. @@8b:    or    [pasMode],sd8bit
  445.  
  446. @@bit:    test    [mode],sdMono        ; force mono?
  447.     jnz    @@mono
  448.     or    [pasMode],sdStereo    ; if not, use stereo
  449.     jmp    @@mst
  450. @@mono: or    [pasMode],sdMono
  451.  
  452. @@mst:    test    [mode],sdLowQ        ; force low or high quality?
  453.     jnz    @@lowq
  454.     test    [mode],sdHighQ
  455.     jnz    @@highq
  456.     or    [pasMode],sdNormalQ    ; if not, use normal quality
  457.     jmp    @@mode
  458. @@lowq: or    [pasMode],sdLowQ
  459.     jmp    @@mode
  460. @@highq:
  461.     or    [pasMode],sdHighQ
  462.  
  463. @@mode: ; pasMode set up OK
  464.  
  465.  
  466.     mov    di,[PAS.port]        ; PAS I/O port
  467.     call    pasSearchHW        ; search for hardware at this port
  468.     cmp    dx,-1            ; hardware found OK?
  469.         jne     @@hwok
  470.  
  471.         mov     ax,errSDFailure         ; Sound Device hardware failure
  472.         jmp     @@err
  473.  
  474. @@hwok:
  475.     mov    [pasVersion],ah     ; save PAS version ID
  476.  
  477.     xor    di,DEFAULT_BASE     ; save port XOR default port
  478.     mov    [_mvTranslateCode],di
  479.  
  480.  
  481.     ; from PAS SDK...
  482.  
  483. ;
  484. ; setup a pointer to our local hardware state table
  485. ;
  486.     mov    bx,offset HardwareShadowTable
  487.         mov     ax,seg HardwareShadowTable
  488.         mov     es,ax
  489.     mov    [word mvhwShadowPointer+0],bx
  490.         mov     [word mvhwShadowPointer+2],es
  491.  
  492.         mov     [es:bx+MVState._audiomixr],31h    ; lowest filter setting
  493.         mov     [es:bx+MVState._crosschannel],09h ; cross channel l-2-l, r-2-r
  494. ;
  495. ; find the int 2F interface and if found, use it's state table pointer
  496. ;
  497.     mov    ax,0BC00h        ; MVSOUND.SYS ID check
  498.     mov    bx,'??'
  499.     sub    cx,cx
  500.     sub    dx,dx
  501.  
  502.     int    2fh            ; will return something if loaded
  503.  
  504.     xor    bx,cx
  505.     xor    bx,dx
  506.     cmp    bx,'MV'                 ; is the int 2F interface here?
  507.     jnz    @@spdone        ; no, exit home
  508.  
  509.     mov    ax,0BC02H        ; get the pointer
  510.     int    2fh
  511.     cmp    ax,'MV'                 ; busy or intercepted
  512.     jnz    @@spdone
  513.  
  514.     mov    [word mvhwShadowPointer+0],bx
  515.     mov    [word mvhwShadowPointer+2],dx
  516. ;
  517. @@spdone:
  518.  
  519.     mov    dx,INTRCTLRST            ; flush any pending PCM irq
  520.     xor    dx,[_mvTranslateCode]        ; xlate the board address
  521.     out    dx,al
  522.  
  523.  
  524.     ; calculate sample rate
  525.  
  526.     les    di,[mvhwShadowPointer]
  527.  
  528.     mov    eax,1193180
  529.     xor    edx,edx
  530.     movzx    ebx,[mixRate]
  531.     div    ebx
  532.     mov    [es:di+MVState._samplerate],ax    ; save output speed
  533.     mov    [pasSpeed],ax
  534.  
  535.     test    [pasMode],sdStereo
  536.     jz    @@nostereo
  537.     mov    ax,[pasSpeed]
  538.     shr    ax,1            ; multiply output rate with 2 if
  539.     mov    [pasSpeed],ax        ; stereo
  540.     mov    [es:di+MVState._samplerate],ax
  541.  
  542. @@nostereo:
  543.     mov    eax,1193180
  544.     xor    edx,edx
  545.     movzx    ebx,[pasSpeed]        ; calculate actual output rate
  546.     div    ebx
  547.  
  548.     test    [pasMode],sdStereo
  549.     jz    @@nostereo2        ; divide with 2 if stereo to get
  550.     shr    eax,1            ; actual output rate
  551.  
  552. @@nostereo2:
  553.     mov    [pasRate],ax
  554.  
  555.     les    di,[mvhwShadowPointer]
  556.     mov    al,00110110b        ; 36h Timer 0 & square wave
  557.     mov    dx,TMRCTLR
  558.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  559.  
  560.     cli
  561.  
  562.     out    dx,al            ; setup the mode, etc
  563.     mov    [es:di+MVState._tmrctlr],al
  564.  
  565.     mov    ax,[es:di+MVState._samplerate]    ; pre-calculated & saved in
  566.     mov    dx,SAMPLERATE            ; prior code
  567.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  568.     out    dx,al            ; output the timer value
  569.  
  570.     jmp    $+2
  571.  
  572.     xchg    ah,al
  573.     out    dx,al
  574.     sti
  575.  
  576.     mov    dx,CROSSCHANNEL
  577.     xor    dx,[_mvTranslateCode]
  578.  
  579.     mov    al,[es:di+MVState._crosschannel]     ; Stop PAS' DMA transfer
  580.     or    al,bCCdrq
  581.     mov    [es:di+MVState._crosschannel],al
  582.     out    dx,al
  583.  
  584.  
  585.     call    dsmInit LANG, [pasRate], [pasMode]
  586.         test    ax,ax                   ; error initializing DSM?
  587.         jnz     @@err
  588.  
  589.     movzx    ax,[PAS.DMA]
  590.     mov    bx,1            ; use auto-initialization
  591.     call    dmaPlayBuffer LANG, seg dsmBuffer offset dsmBuffer, \
  592.         ax, bx            ; start playing the DMA buffer
  593.         test    ax,ax
  594.         jnz     @@err
  595.  
  596.  
  597.     les    di,[mvhwShadowPointer]
  598.     test    [pasMode],sd16bit
  599.     jz    @@no16bit
  600.     mov    cx,(((NOT(bSC216bit+bSC212bit) AND 0FFh)*256) + bSC216bit)
  601.     mov    dx,SYSCONFIG2
  602.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  603.     in    al,dx
  604.     and    al,ch            ; clear the bits
  605.     or    al,cl            ; set the appropriate bits
  606.     out    dx,al
  607. @@no16bit:
  608.     mov    al,bCCmono        ; get the stereo/mono mask bit
  609.     test    [pasMode],sdStereo
  610.     jz    @@nostereox
  611.     sub    al,al
  612. @@nostereox:
  613.     or    al,bCCdac        ; get the direction bit mask
  614.     or    al,bCCenapcm        ; enable the PCM state machine
  615.     mov    dx,CROSSCHANNEL
  616.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  617.  
  618.     mov    ah,0fh + bCCdrq     ; get a mask to load non PCM bits
  619.     and    ah,[es:di+MVState._crosschannel]
  620.                     ; grab all but PCM/DRQ/MONO/DIRECTION
  621.     or    al,ah            ; merge the two states
  622.     xor    al,bCCenapcm        ; disable the PCM bit
  623.     out    dx,al            ; send to the hardware
  624.     jmp    $+2
  625.     xor    al,bCCenapcm        ; enable the PCM bit
  626.     out    dx,al            ; send to the hardware
  627.     mov    [es:di+MVState._crosschannel],al  ; and save the new state
  628. ;
  629. ; Setup the audio filter sample bits
  630. ;
  631.     mov    al,[es:di+MVState._audiofilt]
  632.     or    al,(bFIsrate+bFIsbuff)    ; enable the sample count/buff counters
  633.     mov    dx,AUDIOFILT
  634.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  635.     out    dx,al
  636.     mov    [es:di+MVState._audiofilt],al
  637.  
  638.     mov    al,[es:di+MVState._crosschannel] ; get the state
  639.     mov    dx,CROSSCHANNEL
  640.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  641.     or    al,bCCdrq        ; set the DRQ bit to control it
  642.     out    dx,al
  643.     mov    [es:di+MVState._crosschannel],al ; and save the new state
  644.  
  645. @@ok:
  646.     mov    [PAS.status],sdOK
  647.  
  648.         xor     ax,ax                   ; success
  649.         jmp     @@done
  650.  
  651. @@err:
  652.         ERROR   ID_pasInit
  653.  
  654. @@done:
  655.     ret
  656. ENDP
  657.  
  658.  
  659.  
  660.  
  661. ;/***************************************************************************\
  662. ;*
  663. ;* Function:    int pasClose()
  664. ;*
  665. ;* Description: Uninitializes Pro Audio Spectrum
  666. ;*
  667. ;* Returns:     MIDAS error code
  668. ;*
  669. ;\***************************************************************************/
  670.  
  671. PROC    pasClose    FAR
  672.  
  673.     cmp    [PAS.status],sdOK
  674.     jne    @@err
  675.  
  676.     les    di,[mvhwShadowPointer]
  677. ;
  678. ; clear the audio filter sample bits
  679. ;
  680.     mov    dx,AUDIOFILT
  681.     xor    dx,[_mvTranslateCode]      ; xlate the board address
  682.     cli            ; drop dead...
  683.     mov    al,[es:di+MVState._audiofilt]     ; get the state
  684.     and    al,not (bFIsrate+bFIsbuff) ; flush the sample timer bits
  685.     mov    [es:di+MVState._audiofilt],al     ; save the new state
  686.     out    dx,al
  687.  
  688.     test    [pasMode],sd16bit
  689.     jz    @@no16bit
  690.  
  691. ;
  692. ; disable the 16 bit stuff
  693. ;
  694.     mov    dx,SYSCONFIG2
  695.     xor    dx,[_mvTranslateCode]      ; xlate the board address
  696.     in    al,dx
  697.     and    al,not bSC216bit+bSC212bit ; flush the 16 bit stuff
  698.     out    dx,al
  699. ;
  700. @@no16bit:
  701.  
  702. ;
  703. ; clear the appropriate Interrupt Control Register bit
  704. ;
  705.     mov    ah,bICsampbuff
  706.     and    ah,bICsamprate+bICsampbuff
  707.     not    ah
  708.     mov    dx,INTRCTLR
  709.     xor    dx,[_mvTranslateCode]      ; xlate the board address
  710.     in    al,dx
  711.     and    al,ah            ; kill sample timer interrupts
  712.     out    dx,al
  713.     mov    [es:di+MVState._intrctlr],al
  714.  
  715.     mov    al,[es:di+MVState._crosschannel] ; get the state
  716.     mov    dx,CROSSCHANNEL
  717.     xor    dx,[_mvTranslateCode]    ; xlate the board address
  718.     and    al,not bCCdrq        ; clear the DRQ bit
  719.     and    al,not bCCenapcm    ; clear the PCM enable bit
  720.     or    al,bCCdac
  721.     out    dx,al
  722.  
  723.     mov    [es:di+MVState._crosschannel],al ; and save the new state
  724.  
  725.     movzx    ax,[PAS.DMA]
  726.     call    dmaStop LANG, ax    ; stop DMA playing
  727.         test    ax,ax
  728.         jnz     @@err
  729.  
  730.     call    dsmClose LANG        ; uninitialize DSM
  731.         test    ax,ax
  732.         jnz     @@err
  733.  
  734.     mov    [PAS.status],sdUnInitialized
  735.  
  736.         xor     ax,ax
  737.         jmp     @@done
  738.  
  739. @@err:
  740.         ERROR   ID_pasClose
  741.  
  742. @@done:
  743.     ret
  744. ENDP
  745.  
  746.  
  747.  
  748. END
  749.