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 / _I94F91.INC < prev    next >
Text File  |  1992-08-31  |  10KB  |  510 lines

  1. ;$Author:   BCRANE  $
  2. ;$Date:   31 Aug 1992 09:34:28  $
  3. ;$Header:   X:/sccs/sdkapp/_i94f91.inv   1.1   31 Aug 1992 09:34:28   BCRANE  $
  4. ;$Log:   X:/sccs/sdkapp/_i94f91.inv  $
  5. ;
  6. ;   Rev 1.1   31 Aug 1992 09:34:28   BCRANE
  7. ;added support for 16-bit 
  8. ;
  9. ;   Rev 1.0   29 Jul 1992 16:57:24   BCRANE
  10. ;Initial revision.
  11. ;$Logfile:   X:/sccs/sdkapp/_i94f91.inv  $
  12. ;$Modtimes$
  13. ;$Revision:   1.1  $
  14. ;$Workfile:   _i94f91.inc  $ 
  15.  
  16. ;; shark functions
  17. ;; dx:ax can be used to return values
  18. ;; si can be trashed
  19. ;; no other precautions taken
  20.  
  21.     if VERBOSE
  22.     align 256
  23.     db '_i94f91.inc: copyright Media Vision, Inc., 1992', 00h
  24.     endif
  25.  
  26. DOINT21 equ 1
  27.  
  28. iobf91 struc
  29. f00r    dd    0    ; hardware state table returned from InitMVSound
  30. f01r    dw    0    ; library code version returned from InitPCM
  31. f02c1    dd    0    ; samplerate passed to PCMInfo
  32. f02c2    dw    0    ; mono/stero flag passed to PCMInfo
  33. f02r    dw    0    ; -1 returned by PCMInfo if error, else (?)
  34. f04c    dd    0    ; address of interrupt function or index to internals
  35. f04r    dd    0    ; 0 returned by UserFunc if error, else (?)
  36. f11c1    dd    0    ; not used at present FindDMABuffer
  37. f11c2    dw    0    ; not used at present FindDMABuffer
  38. f11r    dd    0    ; not used at present FindDMABuffer
  39. f03c1    dd    0    ; DMA buffer passed to DMABuffer
  40. f03c2    dw    0    ; size of DMA buffer in kilobytes passed to DMABuffer
  41. f03c3    dw    0    ; number of partitions of DMA buffer passed to DMABuffer
  42. f03r    dd    0    ; 0 returned by DMABuffer if error, else (?)
  43. f10r    dw    0    ; returned by RemovePCM
  44. f05r    dw    0    ; returned by PCMPlay
  45. f07r    dw    0    ; returned by PausePCM
  46. stat    dd    0    ; address of variable to be decremented each DMA pass
  47. fh    dw    0    ; file handle for input file
  48. sbsize    dw    0    ; size of each partition
  49. f02c3    dw    0    ; compression
  50. f02c4    dw    0    ; datasize
  51. iobf91 ends
  52.  
  53. MAXUSERFUNC equ 3    ; Used for ANDing, must be 2^X-1!
  54. uf    dw    offset uf0, offset uf0, offset uf0, offset uf0
  55. iuf    dw    0, 0, 0, 0
  56. iufproc    dw     0
  57.     align 16
  58. ;; f00 -FP    f01 -FP        f02 FP,i-FP    f04 FP-i    
  59. ;; f11 FP,i-FP    f03 FP,i,i-FP    f10 -i        f05 -i        f07 -i
  60. f91state iobf91 <0,     0,     0,0,0,    0,0,    0,0,0,    0,0,0,0,    0,    0,    0>
  61.     align 2
  62.  
  63. ;; i94f91() - perform all initialization code
  64. ;; es:bx points to iobf91 struct
  65. ;; returns status in iobf91 struct
  66.  
  67. _i94f91 proc
  68.     push ds
  69.     push cs
  70.     pop ds
  71.  
  72.     push es
  73.     push di
  74.     push cx
  75.     push ax
  76.     mov ax, cs
  77.     mov es, ax
  78.     mov di, offset f91state
  79.     mov cx, type f91state / 2
  80.     xor ax, ax
  81.     rep stosw
  82.     pop ax
  83.     pop cx
  84.     pop di
  85.     pop es
  86.  
  87. f91_00:
  88.     push es                    ; save before call
  89.     push bx
  90.     call InitMVSound
  91.     pop bx                    ; restore
  92.     pop es
  93.     mov word ptr es:[bx].f00r[0], ax    ; save returned HW State Table
  94.     mov word ptr es:[bx].f00r[2], dx
  95.     or dx, ax
  96.     jnz f91_01
  97.     pop ds
  98.     ret
  99.  
  100. f91_01:
  101.     push es                    ; save before call
  102.     push bx
  103.     call InitPCM
  104.     pop bx                    ; restore
  105.     pop es
  106.     mov es:[bx].f01r, ax
  107.     or ax, ax
  108.     jnz f91_02
  109.     pop ds
  110.     ret
  111.  
  112. f91_02:
  113.     push es                    ; save before call
  114.     push bx
  115.     mov ax, es:[bx].f02c4
  116.     cmp ax, 8
  117.     jz @F
  118.     cmp ax, 16
  119.     jz @F
  120.     cmp ax, 12
  121.     jz @F
  122.     cmp ax, 24
  123.     jz @F
  124.     mov ax, 8
  125. @@:    push ax
  126.  
  127.     mov ax, es:[bx].f02c3
  128.     cmp ax, 1
  129.     jz @F
  130.     cmp ax, 0
  131.     jz @F
  132.     cmp ax, 2
  133.     jz @F
  134.     xor ax, ax
  135. @@:    push ax
  136.  
  137.     mov ax, es:[bx].f02c2
  138.     push ax
  139.     mov ax, word ptr es:[bx].f02c1[2]
  140.     push ax
  141.     mov ax, word ptr es:[bx].f02c1[0]
  142.     push ax
  143.     call PCMInfo
  144.     add sp, 10
  145.     pop bx                    ; restore
  146.     pop es
  147.     mov es:[bx].f02r, ax
  148.     inc ax
  149.     jnz f91_04
  150.     push es                    ; save before call
  151.     push bx
  152.     call RemovePCM
  153.     pop bx                    ; restore
  154.     pop es
  155.     pop ds
  156.     ret
  157.  
  158. f91_04:
  159.     push es                    ; save before call
  160.     push bx
  161.     mov ax, word ptr es:[bx].f04c[2]    ; segment of user function
  162.     or ax, ax                ; non-zero means function
  163.     jnz f91_04a                ; skip ahead
  164.  
  165.     mov ax, cs                ; our code segment
  166.     push ax
  167.     mov bx, word ptr es:[bx].f04c[0]    ; index to internal routines
  168.     and bx, MAXUSERFUNC            ; no out of bounds!
  169.     shl bx, 1                ; word table
  170.     mov ax, cs:uf[bx]            ; get offset from table
  171.  
  172.     mov cs:iufproc, 0            ; set to zero
  173.     cmp cs:iuf[bx], 0            ; is there an initializer?
  174.     jz @F
  175.     mov dx, cs:iuf[bx]
  176.     mov cs:iufproc, dx            ; set for later use
  177. @@:    jmp short f91_uf
  178.     
  179.  
  180. f91_04a:
  181.     push ax
  182.     mov ax, word ptr es:[bx].f04c[0]
  183.  
  184. f91_uf:
  185.     push ax
  186.     call UserFunc
  187.     add sp, 4
  188.     pop bx                    ; restore
  189.     pop es
  190.     mov word ptr es:[bx].f04r[2], dx
  191.     mov word ptr es:[bx].f04r[0], ax
  192.     or dx, ax
  193.     jnz f91getdmabuf
  194.     push es                    ; save before call
  195.     push bx
  196.     call RemovePCM
  197.     pop bx                    ; restore
  198.     pop es
  199.     pop ds
  200.     ret
  201.  
  202. f91getdmabuf:
  203.     mov ax, word ptr es:[bx].f03c1[2]    ; if OURDMABUF set
  204.     or ax, word ptr es:[bx].f03c1[0]
  205.     jnz f91_03                ; skip straight to it
  206.     push es                    ; save before call
  207.     push bx
  208.     call RemovePCM
  209.     pop bx                    ; restore
  210.     pop es
  211.     pop ds
  212.     ret                    ; else fail for now
  213.  
  214. f91_03:
  215.     push es                    ; save before call
  216.     push bx
  217.  
  218.     mov ax, es:[bx].f03c3            ; number of partitions
  219.     push ax
  220.     mov ax, es:[bx].f03c2            ; size of DMA in KB
  221.     push ax
  222.     mov ax, word ptr es:[bx].f03c1[2]    ; segment of DMA buffer
  223.     push ax
  224.     mov ax, word ptr es:[bx].f03c1[0]    ; offset of DMA buffer
  225.     push ax
  226.  
  227.     call DMABuffer
  228.     add sp, 8
  229.  
  230.     pop bx                    ; restore
  231.     pop es
  232.  
  233.     mov word ptr es:[bx].f03r[2], dx    ; save return value
  234.     mov word ptr es:[bx].f03r[0], ax
  235.  
  236.     or dx, ax
  237.     jnz f91_sbsize
  238.     push es                    ; save before call
  239.     push bx
  240.     call RemovePCM
  241.     pop bx                    ; restore
  242.     pop es
  243.     pop ds
  244.     ret
  245.  
  246. f91_sbsize:
  247.     mov ax, es:[bx].f03c2            ; ax= number of partitions
  248.     xor dx, dx                ; zero for division
  249.     mov cx, es:[bx].f03c3
  250.     xor ch, ch                ; no overflows
  251.     or cl, cl                ; no divide by zero crash
  252.     jnz @F
  253.     mov cl, 2
  254. @@:    div cx                    ; div ax by cx
  255.     test byte ptr es:[bx].f03c2[1], 0FFh    ; was dmasize in KB
  256.     jnz @F                    ; no, skip ahead
  257.  
  258.     shl al, 1                ; * 2
  259.     shl al, 1                ; * 4
  260.     mov ah, al                ; * 100h
  261.     xor al, al                ; = amount in bytes
  262. @@:    mov es:[bx].sbsize, ax            ; save partition size in bytes
  263.  
  264. f91_05:
  265.     push es                    ; save before call
  266.     push bx
  267.     call PCMPlay
  268.     pop bx                    ; restore
  269.     pop es
  270.     mov es:[bx].f05r, ax
  271.     push es                    ; save before call
  272.     push bx
  273.     call PausePCM
  274.     pop bx                    ; restore
  275.     pop es
  276.     mov es:[bx].f05r, ax
  277.  
  278.     push ds
  279.     push si
  280.     push es
  281.     push di
  282.     push cx
  283.     push ax
  284.     mov ax, es
  285.     mov ds, ax
  286.     mov si, bx            ;; ds:si has es:bx
  287.     mov ax, cs
  288.     mov es, ax
  289.     mov di, offset f91state        ;; es:di has &iobf91
  290.     mov cx, type f91state / 2    ;; cx has word count
  291.     rep movsw            ;; copy current to our
  292.     pop ax
  293.     pop cx
  294.     pop di
  295.     pop es
  296.     pop si
  297.     pop ds
  298.  
  299.     cmp cs:iufproc, 0            ; is there initialization>
  300.     jz @F                    ; no, skip
  301.     call cs:iufproc                ; yes, perform it
  302. @@:
  303.  
  304.     pop ds
  305.     ret
  306. _i94f91 endp 
  307.  
  308. ;; User Interrupt Functions
  309. uf0 proc far
  310.     push bx                ; save
  311.     push es
  312.  
  313.     push ax                ; save temporarily
  314.     mov ax, word ptr cs:[f91state].stat[2]; get segment address of stat flag
  315.     mov es, ax            ; point to stat flag with es:bx
  316.     mov bx, word ptr cs:[f91state].stat[0]; get offset address of stat flag
  317.     or ax, bx            ; is the address 0?
  318.     pop ax                ; restore temporary save
  319.     jz @F                ; yes, zero, don't affect 
  320.  
  321.     dec byte ptr es:[bx]        ; decrement
  322.     jns @F                ; if not negative, skip
  323.  
  324.     mov byte ptr es:[bx], 0        ; make zero
  325.     
  326. @@:    pop es                ; restore
  327.     pop bx
  328.  
  329.     retf
  330. uf0 endp
  331.  
  332. ;;; removed for time being
  333. if 0
  334. uf1addedsome    dw 0
  335. uf1currentblock    dw 0
  336. uf1 proc far
  337.     push bx                ; save
  338.     push es
  339.     push ax    
  340.  
  341.     mov ax, word ptr cs:[f91state].stat[2]; get segment address of stat flag
  342.     mov es, ax            ; point to stat flag with es:bx
  343.     mov bx, word ptr cs:[f91state].stat[0]; get offset address of stat flag
  344.     or ax, bx            ; is the address 0?
  345.     jnz @F
  346.     jmp uf1_full            ; yes, zero, don't affect 
  347. @@:
  348.     inc word ptr cs:uf1currentblock
  349.     mov ax, cs:[f91state].f03c3
  350.     dec ax
  351.     and cs:[uf1currentblock], ax
  352.  
  353.     dec byte ptr es:[bx]        ; decrement
  354.     jns @F                ; if not negative, skip
  355.  
  356.     mov byte ptr es:[bx], 0        ; make zero
  357.     
  358. @@:    mov ax, es:[bx]            ; get current flag count
  359.     inc ax                ; adjust for zero base
  360.  
  361.     cmp ax, cs:[f91state].f03c3        
  362.     jnb uf1_full            ; DMA buffers are full!
  363.     dec ax                ; unadjust
  364.  
  365.     pushall                ; save state
  366.     mov bx, cs:[f91state].fh    ; get file handle
  367.     mov cx, cs:[f91state].sbsize    ; amount to read in KB
  368.     mov ax, cs:[uf1currentblock]
  369.     xchg ax, cx            ; ax= sbsize, cx= partition number
  370.     mov dx, word ptr cs:[f91state].f03c1[2]
  371.     mov ds, dx
  372.     mov dx, word ptr cs:[f91state].f03c1[0]    ; dx:dx= DMAbuffer
  373.     jcxz uf1_atp0            ; if partition # is 0, skip ahead
  374. @@:    add dx, ax            ; point to next partition 
  375.     loop @B
  376. uf1_atp0:
  377.     xchg ax, cx            ; cx= size to read in bytes
  378. ifdef DOINT21
  379. @@:    call chkindos
  380.     jnz @B
  381.  
  382.     mov ah, 3Fh
  383.     int 21h
  384. else
  385.     mov ax, cx
  386.     clc
  387. endif
  388.     jnc @F                ; no error, skip ahead
  389.     xor ax, ax            ; else zero bytes read
  390.  
  391. @@:    add dx, ax            ; skip into buffer
  392.     mov cs:[uf1addedsome], ax    ; 0= no more to read
  393.     sub cx, ax            ; count to set to silence
  394.     jz @F                ; buffer was filled, ignore
  395.     mov ax, ds
  396.     mov es, ax
  397.     mov di, dx
  398.     mov al, 080h
  399.     rep stosb            ; filled with silence
  400.     
  401. @@:
  402.     cmp cs:[uf1addedsome], 0
  403.     jz @F
  404.  
  405.     push es
  406.     push bx
  407.     mov bx, word ptr cs:[f91state].stat[2]
  408.     mov es, bx
  409.     mov bx, word ptr cs:[f91state].stat[0]
  410.     inc byte ptr es:[bx]
  411.     pop bx
  412.     pop es
  413.  
  414. @@:    popall                ; restore state
  415.  
  416. uf1_full:
  417.     pop ax
  418.     pop es
  419.     pop bx                ; restore
  420.  
  421.     retf
  422. uf1 endp
  423.  
  424. ;; iuf1 - initialize internal user function 1
  425. ;; es:bx= iobf91 struct pointer
  426. ;; read from fh into dmabuf to fill it up
  427.  
  428. iuf1pc    dw    0
  429. iuf1 proc near
  430.  
  431.     pushall
  432.  
  433.     mov di, bx
  434.     mov ax, es:[di].f03c3        ; count of partitions in DMA buf
  435.     mov cs:[iuf1pc], ax
  436.     mov dx, word ptr es:[di].f03c1[2]
  437.     mov ds, dx            ; ds:dx = read buffer
  438.     mov dx, word ptr es:[di].f03c1[0]
  439.     
  440.  
  441. iuf1_read:
  442.     mov cx, es:[di].sbsize        ; size of dma partition in bytes
  443.     push cx                ; save 
  444.  
  445.     mov bx, es:[di].fh        ; file handle
  446. ifdef DOINT21
  447. @@:    call chkindos
  448.     jnz @B
  449.  
  450.     mov ah, 03Fh
  451.     int 021h
  452. else
  453.     xor ax, ax
  454.     clc
  455. endif
  456.  
  457.     jnc @F
  458.     xor ax, ax
  459.  
  460. @@:    sub cx, ax
  461.     jz @F
  462.     push es
  463.     push di
  464.     mov ax, ds
  465.     mov es, ax
  466.     mov di, dx
  467.     rep stosb
  468.     pop di
  469.     pop es
  470.  
  471. @@:    pop cx                ; restore partition size
  472.     add dx, cx            ; next partition
  473.     push es
  474.     push bx
  475.     mov bx, word ptr cs:[f91state].stat[2]
  476.     mov es, bx
  477.     mov bx, word ptr cs:[f91state].stat[0]
  478.     inc byte ptr es:[bx]
  479.     pop bx
  480.     pop es
  481.     dec cs:[iuf1pc]
  482.     jnz iuf1_read
  483.  
  484.     popall
  485.     
  486.     ret
  487. iuf1 endp
  488.  
  489. uf2 proc far
  490.     retf
  491. uf2 endp
  492. uf3 proc far
  493.     retf
  494. uf3 endp
  495.  
  496. chkindos proc near
  497.     push es
  498.     push bx
  499.     mov bx, word ptr cs:[indos][2]
  500.     mov es, bx
  501.     mov bx, word ptr cs:[indos][0]
  502.     cmp byte ptr es:[bx], 0
  503.     pop bx
  504.     pop es
  505.     ret
  506. chkindos endp
  507.  
  508. endif
  509. ;; end of remove for time being
  510.