home *** CD-ROM | disk | FTP | other *** search
/ Audio 4.94 - Over 11,000 Files / audio-11000.iso / msdos / sndbords / proaudio / pcmtlsrc / pcmtlsrc.arj / PCM.ARJ / GETHW.ASM < prev    next >
Assembly Source File  |  1992-09-01  |  14KB  |  486 lines

  1. ;$Author:   BCRANE  $
  2. ;$Date:   01 Sep 1992 13:32:34  $
  3. ;$Header:   X:/sccs/sdkapp/gethw.asv   1.1   01 Sep 1992 13:32:34   BCRANE  $
  4. ;$Log:   X:/sccs/sdkapp/gethw.asv  $
  5. ;  
  6. ;     Rev 1.1   01 Sep 1992 13:32:34   BCRANE
  7. ;  moved data to mvsound.asm, code end of program to be jettisoned on exit
  8. ;  
  9. ;     Rev 1.0   31 Aug 1992 09:46:16   BCRANE
  10. ;  Initial revision.
  11. ;  
  12. ;     Rev 1.4   24 Jul 1992 15:41:14   DCODY
  13. ;  The function now will search for the board in 4 locations if the
  14. ;  user passes in a 0 as the base address.
  15. ;  
  16. ;     Rev 1.3   20 Jul 1992 11:46:18   DCODY
  17. ;  Makes up to 4 passes to find the hardware at up to 4 I/O addresses.
  18. ;  
  19. ;     Rev 1.2   17 Jul 1992 14:02:32   DCODY
  20. ;  moved TheDMAChannel and TheIRQChannel into gethw. Also declared a copy
  21. ;  of mvtranslatecode in the code segment.
  22. ;  
  23. ;     Rev 1.1   23 Jun 1992 16:32:50   DCODY
  24. ;  PAS2 update
  25. ;  
  26. ;     Rev 1.0   15 Jun 1992 09:39:50   BCRANE
  27. ;  Initial revision.
  28. ;$Logfile:   X:/sccs/sdkapp/gethw.asv  $
  29. ;$Modtimes$
  30. ;$Revision:   1.1  $
  31.  
  32.     subttl    GetHW  --  Determine the Pro Audio Spectrum Version
  33.     Subttl    Copyright (c) 1991,1992. Media Vision, Inc. All Rights Reserved
  34.     page    64,131
  35.  
  36. ;   /*\
  37. ;---|*|----====< GetHW >====----
  38. ;---|*|
  39. ;---|*| Get the Pro Audio hardware device configuration, etc.
  40. ;---|*|
  41. ;   \*/
  42.  
  43.         .xlist
  44. ;    include model.inc
  45. ;        include common.inc
  46. ;    include masm.inc
  47. ;    include target.inc
  48.     .list
  49.  
  50. ;
  51. ;   /*\
  52. ;---|*|--------------------------==================--------------------------
  53. ;---|*|
  54. ;---|*|    The Pro AudioSpectrum Plus, Pro AudioSpectrum 16 and CDPC
  55. ;---|*|    all support relocatable I/O.  PAS hardware must occupy four
  56. ;---|*|    contiguous I/O locations.  All I/O accesses use those four addresses
  57. ;---|*|    and their 'harmonic' addresses.  Harmonic addresses are those
  58. ;---|*|    addresses that under normal circumstance would decode to the same
  59. ;---|*|    contiguous four I/O locations.  For example, harmonic addresses of
  60. ;---|*|    port 388h would include 788h, 1388h, 1788h, 1f88h, etc.
  61. ;---|*|
  62. ;---|*|    Most hardware will not conflict with the default address range of
  63. ;---|*|    388h-38Bh.  This address range is based on the I/O locations
  64. ;---|*|    chosen by Adlib and this range is supposed to be reserved for
  65. ;---|*|    SDLC or 2nd Bisynchronous communications hardware.  It has been
  66. ;---|*|    reported that an ISDN card decodes to this range also.  More
  67. ;---|*|    importantly, if a customer wants to have multiple sound cards
  68. ;---|*|    co-resident in his system, we must provide a means of relocating
  69. ;---|*|    the I/O range.
  70. ;---|*|
  71. ;---|*|    Media Vision's I/O relocation capability is software selectable to
  72. ;---|*|    any ONE of 64 4-address locations.  The possible locations are
  73. ;---|*|    depicted below:
  74. ;---|*|
  75. ;---|*|     0     2     4      6    8     A     C      E
  76. ;---|*|
  77. ;---|*|   200h    |<------------- game control------------------->|
  78. ;---|*|
  79. ;---|*|   210h    |<-- expansion unit -->|        |        |
  80. ;---|*|
  81. ;---|*|   220h    |<---- Sound Blaster decode #1 ---------------->|
  82. ;---|*|
  83. ;---|*|   230h    |<---- Sound Blaster decode #2 ---------------->|
  84. ;---|*|
  85. ;---|*|   240h    |<---- Sound Blaster decode #3 ---------------->|
  86. ;---|*|
  87. ;---|*|   250h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  88. ;---|*|
  89. ;---|*|   260h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  90. ;---|*|
  91. ;---|*|   270h    |<---PAS--->|          |<--3rd Parallel Printer->|
  92. ;---|*|
  93. ;---|*|   280h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  94. ;---|*|
  95. ;---|*|   290h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  96. ;---|*|
  97. ;---|*|   2A0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  98. ;---|*|
  99. ;---|*|   2B0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  100. ;---|*|
  101. ;---|*|   2C0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  102. ;---|*|
  103. ;---|*|   2D0h    |<-----------     3270     PC    --------------->|
  104. ;---|*|
  105. ;---|*|   2E0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  106. ;---|*|
  107. ;---|*|   2F0h    |<----- reserved ------>|<-Async comm. 2 ------.|
  108. ;---|*|
  109. ;---|*|     0     2     4      6    8     A     C      E
  110. ;---|*|
  111. ;---|*|   300h    |<401---------- Prototype card ---------------->|
  112. ;---|*|
  113. ;---|*|   310h    |<401---------- Prototype card ---------------->|
  114. ;---|*|
  115. ;---|*|   320h    |<401----------    hard disk   ---------------->|
  116. ;---|*|
  117. ;---|*|   330h    |<401---XT/3270-------->|<---PAS--->|<---PAS--->|
  118. ;---|*|
  119. ;---|*|   340h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  120. ;---|*|
  121. ;---|*|   350h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  122. ;---|*|
  123. ;---|*|   360h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  124. ;---|*|
  125. ;---|*|   370h    |<401, PAS->|          |<--2nd Parallel Printer->|
  126. ;---|*|
  127. ;---|*|   380h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  128. ;---|*|
  129. ;---|*|   390h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  130. ;---|*|
  131. ;---|*|   3A0h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  132. ;---|*|
  133. ;---|*|   3B0h    |<401, Monochrome Display and Parallel 1  ----->|
  134. ;---|*|
  135. ;---|*|   3C0h    |<401, ------------ VGA   --------------------->|
  136. ;---|*|
  137. ;---|*|   3D0h    |<401,-------     3270     PC    --------------->|
  138. ;---|*|
  139. ;---|*|   3E0h    |<401,    reserved ------>|<---- COM 3 serial---->|
  140. ;---|*|
  141. ;---|*|   3F0h    |<401,     Disk     ------>|<-- Asych comm. 1 ---->|
  142. ;---|*|
  143. ;---|*|
  144. ;---|*|
  145. ;---|*|   Note: 401 indicates one of the possible locations of the
  146. ;---|*|     MPU-401 MIDI interface.  It decodes at 3x0 - 3x1 where
  147. ;---|*|     x is an element of {0,1,2,3,4,5,6,7,8,9,a,b,c d,e,f}
  148. ;---|*|
  149. ;---|*|     SoundBlaster decode range is 2x0 thru 2xf where x is
  150. ;---|*|     an element of {2,3,4}
  151. ;---|*|
  152. ;---|*|
  153. ;---|*|   It requires very little effort to support the relocation of
  154. ;---|*|   the hardware if the routines provided here are used.    Once
  155. ;---|*|   the Pro AudioSpectrum chip has been located, any I/O address
  156. ;---|*|   can be relocated by XOR-ing the address (usually contained in)
  157. ;---|*|   the DX register) with a 16-bit variable.
  158. ;---|*|
  159. ;   \*/
  160. ;
  161.  
  162. ;
  163. ;---------------------------========================---------------------------
  164. ;---------------------------====< CODE SECTION >====---------------------------
  165. ;---------------------------========================---------------------------
  166. ;
  167.     .code
  168.  
  169.     public    _csMVTranslateCode
  170. _csMVTranslateCode    dw    0    ; I/O base xor default_base
  171.  
  172. ;
  173. ;   /*\
  174. ;---|*|----====< long mvGetHWVersion() >====----
  175. ;---|*|
  176. ;---|*| Detects and identifies the installed Pro AudioSpectrum.
  177. ;---|*|
  178. ;---|*| Entry Conditions:
  179. ;---|*|     word address containing the base address.
  180. ;---|*|
  181. ;---|*| Exit Conditions:
  182. ;---|*|     DX:AX = -1, the hardware is not installed.
  183. ;---|*|     DX:AX = -2, some type of hardware is installed - can't ID it.
  184. ;---|*|     DX      = Product ID
  185. ;---|*|     AH      = PAS hardware version
  186. ;---|*|     AL      = SCSI, or MITSUMI CD-ROM interface installed.
  187. ;---|*|     BX:CX = the bit fields that identify the board
  188. ;---|*|     Carry is set on error
  189. ;---|*|
  190. ;   \*/
  191.  
  192.     public    mvGetHWVersion
  193. mvGetHWVersion    proc
  194.     push    bp            ; frame the stack
  195.     mov    bp,sp
  196.  
  197.     push    si            ; save the C criticals
  198.     push    di
  199. ;
  200. ; calculate the translation code
  201. ;
  202.     mov    di,wParm1        ; get the base I/O address
  203.  
  204.     .errnz    USE_ACTIVE_ADDR
  205.     or    di,di            ; do we search just one?
  206.     jnz    mvgehw_05        ; yes, pass it on...
  207.  
  208.     ; search the default address
  209.  
  210.         mov     di,DEFAULT_BASE         ; try the first address
  211.     call    SearchHWVersion
  212.     cmp    dx,-1            ; found?
  213.     jnz    mvgehw_exit        ; yes, exit now...
  214.  
  215.     ; search the first alternate address
  216.  
  217.     mov    di,ALT_BASE_1        ; try the first alternate
  218.     call    SearchHWVersion
  219.     cmp    dx,-1            ; found?
  220.     jnz    mvgehw_exit        ; yes, exit now...
  221.  
  222.     ; search the second alternate address
  223.  
  224.     mov    di,ALT_BASE_2        ; try the second alternate
  225.     call    SearchHWVersion
  226.     cmp    dx,-1            ; found?
  227.     jnz    mvgehw_exit        ; yes, exit now...
  228.  
  229.     ; search the third, or user requested alternate address
  230.  
  231.     mov    di,ALT_BASE_3        ; try the third alternate
  232. ;
  233. mvgehw_05:
  234.     call    SearchHWVersion     ; pass the third A, or user I/O
  235. ;
  236. mvgehw_exit:
  237.     pop    di
  238.     pop    si
  239.     pop    bp
  240.     ret
  241.  
  242. mvGetHWVersion    endp
  243.  
  244. ;
  245. ;   /*\
  246. ;---|*|----====< SearchHWVersion >====----
  247. ;---|*|
  248. ;---|*| Given a specific I/O address, this routine will see if the
  249. ;---|*| hardware exists at this address.
  250. ;---|*|
  251. ;---|*| Entry Conditions:
  252. ;---|*|     DI holds the I/O address to test
  253. ;---|*|     BX:CX = bMVSCSI
  254. ;---|*|
  255. ;---|*| Exit Conditions:
  256. ;---|*|     BX:CX = the bit fields that identify the board
  257. ;---|*|
  258. ;   \*/
  259. ;
  260. SearchHWVersion proc near
  261.     push    si            ; save the C criticals
  262.     push    di
  263. ;
  264. ; calculate the translation code
  265. ;
  266.     xor    di,DEFAULT_BASE     ; di holds the translation code
  267. ;
  268. ; grab the version # in the interrupt mask. The top few bits hold the version #
  269. ;
  270.     mov    ax,0BC00H        ; make sure MVSOUND.SYS is loaded
  271.     mov    bx,'??'                 ; this is our way of knowing if the
  272.     xor    cx,cx            ; hardware is actually present.
  273.     xor    dx,dx
  274.     int    2fh            ; get the ID pattern
  275.     xor    bx,cx            ; build the result
  276.     xor    bx,dx
  277.     cmp    bx,'MV'                 ; if not here, exit...
  278.     jjnz    sehw_bad
  279. ;
  280. ; get the MVSOUND.SYS specified DMA and IRQ channel
  281. ;
  282.         mov     ax,0bc04h               ; get the DMA and IRQ numbers
  283.     int    2fh
  284.     mov    TheDMAChannel,bl    ; save the correct DMA & IRQ
  285.     mov    TheIRQChannel,cl
  286.  
  287.         mov     dx,INTRCTLR             ; board ID is in MSB 3 bits
  288.     xor    dx,di            ; adjust to other address
  289.     in    al,dx
  290.     cmp    al,-1            ; bus float meaning not present?
  291.     je    sehw_bad        ; yes, there is no card here
  292.  
  293.     mov    ah,al            ; save an original copy
  294.     xor    al,fICrevbits        ; the top bits wont change
  295.  
  296.     out    dx,al            ; send out the inverted bits
  297.     pause
  298.         pause
  299.     in    al,dx            ; get it back...
  300.  
  301.     cmp    al,ah            ; both should match now...
  302.     xchg    al,ah            ; (restore without touching the flags)
  303.     out    dx,al
  304.  
  305.     jnz    sehw_bad        ; we have a bad board
  306.  
  307.         and     ax,fICrevbits           ; isolate the ID bits & clear AH
  308.     mov    cl,fICrevshr        ; shift the bits into a meaningful
  309.     shr    al,cl            ; position (least signficant bits)
  310.     mov    si,ax            ; save the version #
  311. ;
  312. ; We do have hardware! Load the product bit definitions
  313. ;
  314.     sub    bx,bx
  315.     mov    cx,bMVSCSI        ; setup bx:cx for the original PAS
  316.  
  317.         or      al,al                   ; is this the first version of h/w?
  318.     jz    sehw_done        ; yes, simple exit will do.
  319.  
  320.     call    FindBits        ; load all the rest of the h/w bits
  321. ;
  322. sehw_done:
  323. ;
  324. ; loop on a table search to find identify the board
  325. ;
  326.     push    bx            ; save this high bits
  327.     mov    bx,-2
  328.     ;
  329.     sehw_05:
  330.     add    bx,2
  331.     cmp    ProductIDTable[bx],-1    ; at the end of the table?
  332.     jz    sehw_bad_hw        ; yes, we can't identify this board
  333.     mov    dx,cx            ; dx holds the product bits
  334.     and    dx,DoCareBits[bx]    ; keep the bits we care about
  335.     cmp    dx,ProductIDTable[bx]    ; do these bits match a product?
  336.     jnz    sehw_05         ; no, keep looking
  337.  
  338.     mov    dx,bx
  339.     shr    dx,1            ; make word index a byte index
  340.     pop    bx
  341.  
  342.     mov    [_MVTranslateCode],di       ; save the translation code
  343.     mov    cs:[_csMVTranslateCode],di ; save the translation code
  344.  
  345.     mov    ax,si            ; load the h/w version #
  346.     sub    ah,ah            ; for our purposes, we will return SCSI
  347.     xchg    ah,al            ; into ah
  348.         clc                             ; The board was identified !
  349.  
  350.     mov    [_mvHWVersionBits],cx    ; save the good bits
  351.  
  352.     jmp    short sehw_exit
  353. ;
  354. sehw_bad_hw:
  355.     pop    bx            ; flush the stack
  356.     mov    ax,-2
  357.     cwd
  358.     stc
  359.     jmp    short sehw_exit
  360. ;
  361. sehw_bad:
  362.     mov    ax,-1            ; we got here due to a bad board
  363.     cwd
  364. ;
  365. sehw_exit:
  366.     pop    di
  367.     pop    si
  368.     ret
  369.  
  370. SearchHWVersion endp
  371.  
  372. ;
  373. ;   /*\
  374. ;---|*|----====< FindBit >====----
  375. ;---|*|
  376. ;---|*| Checks the installed hardware for all the feature bits.
  377. ;---|*|
  378. ;---|*| Entry Conditions:
  379. ;---|*|     DI holds the I/O address translation code
  380. ;---|*|     BX:CX = bMVSCSI
  381. ;---|*|
  382. ;---|*| Exit Conditions:
  383. ;---|*|     BX:CX = the bit fields that identify the board
  384. ;---|*|
  385. ;   \*/
  386. ;
  387.  
  388. FindBits        proc    near
  389. ;
  390. ; All second generation Pro Audio cards use the MV101 and have SB emulation.
  391. ;
  392.     or    cx,bMVSBEMUL+bMV101    ; force SB emulation
  393. ;
  394. ; determine if the enhanced SCSI interface is present
  395. ;
  396.         mov     dx,ENHANCEDSCSI         ; test for SCSI mod (U48)
  397.     xor    dx,di            ; modify via the translate code
  398.  
  399.     out    dx,al            ; strobe
  400.     pause                ; I/O bus delay
  401.     in    al,dx            ; get the bit
  402.  
  403.     and    al,1            ; bit0==1 means old SCSI PAL
  404.     cmp    al,1            ; reverse sense
  405.     sbb    ax,ax            ; ax = ffff if enhanced SCSI
  406.     and    ax,bMVENHSCSI        ; save the bit
  407.     or    cx,ax            ; merge it in
  408. ;
  409. ; determine AT/PS2, CDPC slave mode
  410. ;
  411.     mov    dx,MASTERMODRD        ; check for the CDPC
  412.         xor     dx,di                   ; modify via the translate code
  413.  
  414.         in      al,dx
  415.     test    al,bMMRDatps2        ; AT(1) or PS2(0)
  416.     jnz    @F
  417.     or    cx,bMVPS2
  418.     ;
  419.     @@:
  420.     test    al,bMMRDmsmd        ; Master(0) or Slave(1)
  421.     jz    @F
  422.     or    cx,bMVSLAVE
  423.     ;
  424.     @@:
  425.     push    cx            ; move the revision bits
  426.  
  427.     mov    dx,MASTERCHIPR
  428.     xor    dx,di
  429.  
  430.     .errnz    bMV101_REV-(000Fh SHL 11)
  431.  
  432.     in    al,dx            ; get the low 4 bits of the chip rev
  433.     and    ax,000Fh        ; into ah
  434.     mov    cl,11            ; FROM 0000 0000 0000 1111b
  435.     shl    ax,cl            ; TO   0111 1000 0000 0000b
  436.  
  437.         pop     cx
  438.         or      cx,ax                   ; merge in the bits
  439. ;
  440. ; determine the CDROM drive type, FM chip, 8/16 bit DAC, and mixer
  441. ;
  442.     mov    dx,SLAVEMODRD        ; check for the CDPC
  443.         xor     dx,di                   ; modify via the translate code
  444.     in    al,dx
  445.  
  446.         test    al,bSMRDdactyp          ; 16 bit DAC?
  447.     jz    @F            ; no, its an 8 bit DAC
  448.     or    cx,bMVDAC16        ; its a 16 bit DAC
  449.     ;
  450.     @@:
  451.     test    al,bSMRDfmtyp        ; OPL3 chip?
  452.     jz    @F            ; no, so it's the PAS16 card
  453.     or    cx,bMVOPL3        ; is an OPL3
  454.     ;
  455.     @@:
  456.     mov    dx,cx            ; inference check for new mixer
  457.     and    dx,bMVSLAVE+bMVDAC16    ; Slave & 16 bit dac is the CDPC
  458.     cmp    dx,bMVDAC16        ; 16 bit DAC on master?
  459.     jnz    @F            ; no, it's the CDPC with Nation mixer
  460.     or    cx,bMVA508
  461.     ;
  462.     @@:
  463.     and    al,bSMRDdrvtyp        ; isolate the CDROM drive type
  464.     cmp    al,2            ; Sony 535 interface?
  465.     jnz    @F            ; no, continue on...
  466.     and    cx,NOT (bMVSCSI+bMVENHSCSI) ; yes, flush the SCSI bits
  467.     or    cx,bMVSONY            ; set the 535 bit
  468.     ;
  469.     @@:
  470. ;
  471. ; determine if MPU-401 emulation is active
  472. ;
  473.         mov     dx,COMPATREGE           ; compatibility register
  474.     xor    dx,di            ; modify via translate code
  475.     in    al,dx
  476.     test    al,cpMPUEmulation
  477.     jz    @F
  478.     or    cx,bMVMPUEMUL
  479.     ;
  480.     @@:
  481.     ret
  482.  
  483. FindBits    endp
  484.  
  485.  
  486.