home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / dmkit / flat / digplay.asm < prev    next >
Encoding:
Assembly Source File  |  1993-12-31  |  9.7 KB  |  416 lines

  1. ;;************ DIGPLAY.ASM, flat-model link layer to DIGPAK functions.
  2. ;;************ written using Borland Assembler in IDEAL mode.  Assumes
  3. ;;************ a DPMI with a flat model address space where selectors
  4. ;;************ DS and ES always point to flat address 0000000000000h!
  5. ;;************ Written and tested with DOS4GW and Watcom C.  Uses
  6. ;;************ standard C calling convention.  Getting this to work
  7. ;;************ under any other DPMI is an excercise left for ths student.
  8. ;;************ Warning!! The Watcom compiler passes 4 bytes on the stack
  9. ;;************ to a cdecl external routine, even if the parameter is only
  10. ;;************ a char.    All of these assembly routines have been defined
  11. ;;************ this way.  If you are usinga compiler that passes different
  12. ;;************ size arguments to cdecl routines, you may want to double
  13. ;;************ check for compatibilities sake.
  14. ;;************ The FLAT-MODEL DIGPAK DOES NOT SUPPORT 8253 TIMER BASED
  15. ;;************ DRIVERS!  Their interrupt requirements are too excessive
  16. ;;************ and create too many incompatibility problems for protected
  17. ;;************ mode applications.
  18. ;;***
  19. ;;*** Written by John W. Ratcliff (c) 1994
  20. ;;***         Compuserve: 70253,3237
  21. ;;***         Genie: J.RATCLIFF3
  22. ;;***         BBS: 1-314-939-0200
  23. ;;***         Addresss:
  24. ;;***               747 Napa Lane
  25. ;;***               St. Charles, MO 63304
  26. ;;***
  27. ;;***     A $500 per product license fee applies to all commercial software
  28. ;;***     products distributed with any DIGPAK drivers.
  29. ;;***     To pay a license, simply write a check for $500 payable to
  30. ;;***     The Audio Solution, 747 Napa Lane, St. Charles, MO 63304
  31. ;;***     with a copy of your commerical product.  You will receive a signed
  32. ;;***     license agreement from The Audio Solution shortly thereafter.
  33. ;;***     This license fee applies specifically to the inclusion with your
  34. ;;***     distribution disk any of the DIGPAK drivers from The Audio Solution
  35. ;;***     These drivers are copyrighted works, created by me, to enhance the
  36. ;;***     use of sound and music in DOS based commercial software.     The
  37. ;;***     license fees collected are used to maintain the drivers and keep
  38. ;;***     the BBS running.     There is a seperate license fee for the use
  39. ;;***     and distribution of MIDPAK drivers.
  40. ;;***     See accompaning documentation regarding license fees for MIDPAK
  41. ;;***     distribution.    You would be ill-advised to distribute a commercial
  42. ;;***     product containing either DIGPAK and/or MIDPAK drivers without
  43. ;;***     having paid the distribution license fee.  Since your product would
  44. ;;***     contain unlicensed copyrighted software from The Audio Solution,
  45. ;;***     your product could be immediatly required to be removed from retail
  46. ;;***     distribution.    I doubt this is going to be a problem.    Clearly if
  47. ;;***     your product is enhanced by the use of these drivers, your company
  48. ;;***     can easily afford a nominal license fee of $500 in exchange for
  49. ;;***     getting the use of several man-years of software engineering
  50. ;;***     resources.
  51. ;;******************************************************************************
  52.  
  53.  
  54.     IDEAL
  55.     P386
  56.     JUMPS
  57.     MODEL FLAT,C
  58.  
  59.     CODESEG
  60.  
  61.     public    CheckIn
  62.     public    DigPlay
  63.     public    SetDPMIMode
  64.     public    ReportVersionNumber
  65.     public    SoundStatus
  66.     public    MassageAudio
  67.     public    DigPlay2
  68.     public    AudioCapabilities
  69.     public    DigPakIdentityString
  70.     public    StopSound
  71.     public    WaitSound
  72.     public    PostAudioPending
  73.     public    AudioPendingStatus
  74.     public    SetStereoPan
  75.     public    SetPlayMode
  76.     public    PendingAddress
  77.     public    ReportSemaphoreAddress
  78.     public    SetRecordMode
  79.     public    SetBackFillMode
  80.     public    ReportDMAC
  81.     public    NullSound
  82.     public    VerifyDMA
  83.     public    InitDP
  84.     public    DeInitDP
  85.  
  86. ;; DIGPAK sound function equates.
  87.  
  88. DIG_DIGPLAY    equ    688h
  89. DIG_SOUNDSTATUS equ    689h
  90. DIG_MASSAGEAUDIO equ    68Ah
  91. DIG_DIGPLAY2    equ    68Bh
  92. DIG_AUDIOCAP    equ    68Ch
  93. DIG_IDENTITY    equ    68Ch
  94. DIG_STOPSOUND    equ    68Fh
  95. DIG_POSTPEND    equ    695h
  96. DIG_PENDSTATUS    equ    696h
  97. DIG_STEREOPAN    equ    697h
  98. DIG_PLAYMODE    equ    698h
  99. DIG_PENDADDRESS equ    699h
  100. DIG_SEMAPHORE    equ    699h
  101. DIG_DIVISOR    equ    693h
  102. DIG_RECORD    equ    69Ah
  103. DIG_BACKFILL    equ    69Ch
  104. DIG_REPORTDMA    equ    69Dh
  105. DIG_VERIFYDMA    equ    69Eh
  106. DIG_REPORTVERSION equ    689h
  107. DIG_SETDPMIMODE equ    6A0h
  108.  
  109. SOUNDINT    equ    66h    ; Interrupt vector.
  110.  
  111. Proc    C CheckIn    near
  112.     uses    ebx,ds,es
  113.  
  114.     mov    ebx,SOUNDINT*4h
  115.     mov    eax,[ds:ebx]    ; Get addresss or interrupt vector.
  116.     or    eax,eax
  117.     jz    @@CIOUT     ; Exit if vector is null.
  118.     mov    bx,ax        ; Get offset portion.
  119.     shr    eax,(16-4)    ; Get segment portion down.
  120.     and    eax,0FFFFF0h
  121.     add    ebx,eax     ; now have real-address.
  122.     sub    ebx,6        ; point back to identifier
  123.     xor    eax,eax     ; Zero out entire EAX return register.
  124.  
  125.     cmp    [word ebx],'IM'  ; Midi driver?
  126.     jne    @@NEX
  127.     cmp    [word ebx+2],'ID'  ; full midi driver identity string?
  128.     jne    @@NEX
  129. ;; Ok, a MIDI driver is loaded at this address.
  130.     mov    ax,701h     ; Digitized Sound capabilities request.
  131.     int    SOUNDINT         ; Request.
  132.     or    ax,ax        ; digitized sound driver available?
  133.     jnz    @@OK        ; yes, report that to the caller.
  134.     jz    @@CIOUT     ; exit, sound driver not available.
  135. @@NEX:
  136.     cmp    [word ebx],454Bh ; equal?
  137.         jne     @@CIOUT         ; exit if not equal
  138.     cmp    [word ebx+2],4E52h    ; equal?
  139.         jne     @@CIOUT
  140. @@OK:    mov    ax,1
  141. @@EXT:
  142.     ret
  143. @@CIOUT: xor    ax,ax        ; Zero return code.
  144.     jmp short @@EXT
  145.     endp
  146.  
  147. Proc    C DigPlay    near
  148.     ARG    SND:DWORD
  149.     uses    esi,ds,es
  150.  
  151.     mov    esi,[SND]
  152.     mov    eax,DIG_DIGPLAY
  153.     int    SOUNDINT
  154.  
  155.     ret
  156.     endp
  157.  
  158. Proc    C SetDPMIMode    near
  159.     ARG    MODE:DWORD
  160.     uses    edx,ds,es
  161.  
  162.     mov    edx,[MODE]
  163.     mov    ax,DIG_SETDPMIMODE
  164.     int    SOUNDINT
  165.  
  166.     ret
  167.     endp
  168.  
  169. PROC    C ReportVersionNumber    near
  170.     uses    ebx,ds,es
  171.     xor    ebx,ebx       ; Default version number.
  172.     mov    eax,DIG_REPORTVERSION         ; Get version number/status call.
  173.     int    SOUNDINT
  174.     mov    eax,ebx       ; Return version number.
  175.     ret
  176.     endp
  177.  
  178. Proc    C SoundStatus near
  179.     uses    ds,es
  180.     mov    eax,DIG_SOUNDSTATUS      ; Check sound status.
  181.     int    SOUNDINT         ; Sound driver interrupt.
  182.     ret
  183.     endp
  184.  
  185. Proc    C MassageAudio      near
  186.     ARG    DATA:DWORD
  187.     uses    esi,ds,es
  188.  
  189.     mov    eax,DIG_MASSAGEAUDIO       ; Identity
  190.     mov    esi,[DATA]    ; Data structure.
  191.     int    SOUNDINT         ; Do sound interupt.
  192.  
  193.     ret
  194.     endp
  195.  
  196. Proc    C DigPlay2 near
  197.     ARG    DATA:DWORD
  198.     uses    esi,ds,es
  199.  
  200.     mov    eax,DIG_DIGPLAY2    ; Identity
  201.     mov    esi,[DATA]     ; Data structure.
  202.     int    SOUNDINT         ; Do sound interupt.
  203.  
  204.     ret
  205.     endp
  206.  
  207. Proc    C AudioCapabilities near
  208.     uses    ds,es
  209.     mov    eax,DIG_AUDIOCAP
  210.     int    SOUNDINT
  211.     ret
  212.     endp
  213.  
  214. Proc    C DigPakIdentityString near
  215.         ARG     string:DWORD
  216.     uses    ebx,ecx,esi,edi,ds,es
  217.  
  218.     xor    ecx,ecx     ; Zero high portion of ECX
  219.     xor    ebx,ebx     ; Zero ebx
  220.     mov    eax,DIG_IDENTITY
  221.     int    SOUNDINT
  222.     mov    edi,[string]
  223.     mov    esi,ebx     ; Get segment.
  224.     shl    esi,4        ; Into flat-model address space.
  225.     add    esi,ecx     ; Add the offset portion.
  226.     mov    ecx,-1
  227. @@MV:   lodsb
  228.         stosb
  229.     inc    ecx
  230.     or    al,al
  231.     jnz    @@MV
  232.     mov    eax,ecx       ; Return string length.
  233.  
  234.     ret
  235.     endp
  236.  
  237. ;; void StopSound(void);    // 68Fh -> Stop current sound from playing.
  238. Proc    C StopSound near
  239.     uses    ds,es
  240.     mov    eax,DIG_STOPSOUND
  241.     int    SOUNDINT
  242.     ret
  243.     endp
  244.  
  245. Proc    C WaitSound near
  246.     uses    ds,es
  247. @@WS:    mov    eax,DIG_SOUNDSTATUS
  248.     int    SOUNDINT
  249.     or    ax,ax
  250.     jnz    @@WS
  251.     ret
  252.     endp
  253.  
  254. Proc    C PostAudioPending near
  255.     ARG    SOUND:DWORD
  256.     uses    edi,ds,es
  257.     mov    esi,[SOUND]
  258.     mov    eax,DIG_POSTPEND
  259.     int    SOUNDINT
  260.     ret
  261.     endp
  262.  
  263. PROC    C AudioPendingStatus near
  264.     uses    ds,es
  265.     mov    eax,DIG_PENDSTATUS
  266.     int    SOUNDINT
  267.     ret
  268.     endp
  269.  
  270. Proc    C SetStereoPan near
  271.     ARG    PAN:DWORD
  272.     uses    edx,ds,es
  273.     mov    edx,[PAN]
  274.     mov    eax,DIG_STEREOPAN
  275.     int    SOUNDINT
  276.     ret
  277.     endp
  278.  
  279. Proc    C SetPlayMode
  280.     ARG    MODE:DWORD
  281.     uses    edx,ds,es
  282.     mov    edx,[MODE]
  283.     mov    eax,DIG_PLAYMODE
  284.     int    SOUNDINT
  285.     ret
  286.     endp
  287.  
  288. Proc    C PendingAddress near
  289.     uses    edx,ds,es
  290.     xor    edx,edx
  291.     mov    eax,DIG_PENDADDRESS
  292.     int    SOUNDINT
  293.     shl    edx,4        ; Into flat-model address space.
  294.     add    eax,edx     ; Form full flat-model address.
  295.     ret
  296.     endp
  297.  
  298. Proc    C ReportSemaphoreAddress near
  299.     uses    ebx,edx,ds,es
  300.     xor    edx,edx
  301.     xor    ebx,ebx
  302.     mov    ax,DIG_SEMAPHORE
  303.     int    SOUNDINT
  304.     mov    eax,edx     ; get segment.
  305.     shl    eax,4        ; into flat space.
  306.     add    eax,ebx     ; Add offset portion.
  307.     ret
  308.     endp
  309.  
  310. Proc    C  SetRecordMode near
  311.     ARG    MODE:DWORD
  312.     uses    edx,ds,es
  313.     mov    edx,[MODE]
  314.     mov    eax,DIG_RECORD
  315.     int    SOUNDINT
  316.     ret
  317.     endp
  318.  
  319.  
  320. Proc    C SetBackFillMode near
  321.     ARG    MODE:DWORD
  322.     uses    edx,ds,es
  323.     mov    edx,[MODE]
  324.     mov    eax,DIG_BACKFILL
  325.     int    SOUNDINT
  326.     ret
  327.     endp
  328.  
  329. Proc    C ReportDMAC near
  330.     uses    ds,es
  331.     mov    eax,DIG_REPORTDMA
  332.     int    SOUNDINT
  333.     ret
  334.     endp
  335.  
  336.  
  337. Proc    C NullSound near
  338.     ARG    SOUND:DWORD,SNDLEN:DWORD,VALUE:DWORD
  339.     uses    ecx,edi
  340.  
  341.     mov    edi,[SOUND]
  342.     mov    eax,[VALUE]
  343.     mov    ecx,[SNDLEN]
  344.     rep    stosb
  345.  
  346.     ret
  347.     endp
  348.  
  349. Proc    C VerifyDMA near
  350.     ARG    SDATA:DWORD,SLEN:DWORD
  351.     uses    ebx,ecx,ds,es
  352.     mov    ebx,[SDATA]
  353.     mov    ecx,[SLEN]
  354.     mov    eax,DIG_VERIFYDMA
  355.     int    SOUNDINT
  356.     ret
  357.     endp
  358.  
  359.  
  360. Proc    C InitDP near
  361.     ARG    DIGPAK:DWORD
  362.     uses    ebx,ecx,esi,edi,ds,es
  363.  
  364.     mov    ebx,[DIGPAK]    ; Get the address of the 'supposed' DIGPAK.
  365.     cmp    [byte ebx+3],'D'        ; Does it say digpak?
  366.     jne    @@FREE
  367.     cmp    [byte ebx+4],'I'        ;
  368.     jne    @@FREE
  369.     cmp    [byte ebx+5],'G'
  370.     jne    @@FREE
  371.     cmp    [byte ebx+6],'P'
  372.     jne    @@FREE
  373.     cmp    [byte ebx+7],'A'
  374.     jne    @@FREE
  375.     cmp    [byte ebx+8],'K'
  376.     jne    @@FREE
  377. ;; Ok, it SAY's DIGPAK.
  378.     shr    ebx,4        ; Into segment size.
  379.     sub    ebx,10h     ; org 100h, segment
  380.     mov    ecx,200h    ; offset
  381.     mov    eax,0301h    ; simulate realmode far proc.
  382.     int    66h
  383.     or    ax,ax
  384.     jnz    @@FREE
  385.     mov    ax,1        ; Success.
  386. @@RET:
  387.     ret
  388. @@FREE:
  389.     xor    ax,ax    ; Zero failed return code
  390.     jmp short @@RET
  391.     endp
  392.  
  393. Proc    C DeInitDP near
  394.     ARG    DIGPAK:DWORD
  395.     uses    ebx,ecx,esi,edi,ds,es
  396.  
  397.     mov    ebx,[DIGPAK]
  398.     shr    ebx,4        ; Into segment size.
  399.     sub    ebx,10h     ; org 100h
  400.     mov    ecx,203h    ; offset.
  401.     mov    eax,0301h    ; simulate realmode far proc.
  402.     int    66h
  403.     or    ax,ax
  404.     jnz    @@FREE
  405.     mov    ax,1        ; Success.
  406. @@RET:
  407.     ret
  408. @@FREE:
  409.     xor    ax,ax    ; Zero failed return code
  410.     jmp short @@RET
  411.     ret
  412.     endp
  413.  
  414.     ends
  415.     end
  416.