home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / prg / dsik205 / dsik.dat / EXAMPLES / EXAMP12.ASM < prev    next >
Assembly Source File  |  1995-04-10  |  5KB  |  152 lines

  1. ;/***************************************************************************
  2. ;*
  3. ;*                   Digital Sound Interface Kit (DSIK)
  4. ;*                            Version 2.00
  5. ;*
  6. ;*                           by Carlos Hasan
  7. ;*
  8. ;* Filename:    example12.asm
  9. ;* Version:     Revision 1.0
  10. ;*
  11. ;* Language:    Turbo Assembler 4.0 (Ideal Mode)
  12. ;* Environment: IBM PC (DOS/4GW)
  13. ;*
  14. ;* Description: Play a music module file. This is just a simple assembly
  15. ;*              example to show how to interface with the sound system
  16. ;*              from an assembly language program.
  17. ;*
  18. ;* NOTE:        If you do not use TASM ideal mode, the AUDIO.INC file
  19. ;*              and this example file are not very useful. If you want
  20. ;*              to compile this example, type at the DOS prompt:
  21. ;*                  tasm -m -q -ml -p -t -i..\include examp12.asm
  22. ;*                  wcl386 -zq -l=dos4g -"libpath ..\lib" examp12.obj
  23. ;*
  24. ;***************************************************************************/
  25.  
  26. ideal
  27. p386
  28. model flat,c
  29.  
  30. include "audio.inc"
  31.  
  32. ; link the WATCOM C run-time library (register calling convention library)
  33. includelib "clib3r.lib"
  34.  
  35. ;[]------------------------------------------------------------------------[]
  36. ; If you do not want to link the C run-time library in your 100% assembly
  37. ; programs you have two alternatives:
  38. ;   a) Rewrite the highlevel MODLOAD.C routines in assembly language, or
  39. ;   b) Rewrite the run-time routines used in the MODLOAD.C source file.
  40. ; However, if you do not link the C run-time library the DOS/4GW v1.95 (and
  41. ; above) 32-bit DOS extender won't execute your programs, because your
  42. ; program won't be recognized like a WATCOM application. You can use DOS/4G
  43. ; or PMODE/W DOS extenders for your 100% assembly programs.
  44. ;[]------------------------------------------------------------------------[]
  45.  
  46. dataseg
  47.  
  48. ErrMsg0     db      'Please run SETUP.EXE to configure.',10,13,'$'
  49. ErrMsg1     db      'Error initializing the sound system.',10,13,'$'
  50. ErrMsg2     db      'Error loading SONG.DSM module file.',10,13,'$'
  51. OkMsg       db      'Playing module. Press any key to continue.',10,13,'$'
  52. SetupFile   db      'SETUP.CFG',0       ; setup filename
  53. SongFile    db      'SONG.DSM',0        ; module filename
  54.  
  55. udataseg
  56.  
  57. SC          SoundCard   ?               ; soundcard structure
  58. M           dd          ?               ; module pointer
  59.  
  60. codeseg
  61.  
  62. ;/***************************************************************************
  63. ;*
  64. ;* Function:    main_
  65. ;* Parameters:  EAX     - number of arguments
  66. ;*              EDX     - arguments vector
  67. ;*
  68. ;* Returns:     Return zero on success.
  69. ;*
  70. ;* Description: Main routine called by the WATCOM run-time code.
  71. ;*
  72. ;***************************************************************************/
  73.  
  74. global nolanguage main_:proc
  75. proc main_ nolanguage
  76.         pushad
  77.  
  78. ; first register all the audio drivers using the dRegisterDrivers macro.
  79.         dRegisterDrivers
  80.  
  81. ; load the setup configuration file from disk
  82.         lea     eax,[SC]
  83.         lea     edx,[SetupFile]
  84.         call    dLoadSetup
  85.         test    eax,eax
  86.         je      mainf0
  87.         mov     ah,09h                  ; if error loading the file,
  88.         lea     edx,[ErrMsg0]           ; print message and exit.
  89.         int     21h
  90.         jmp     maind1
  91.  
  92. ; initialize the DSIK 2.0 sound system . . .
  93. mainf0:
  94.         lea     eax,[SC]
  95.         call    dInit
  96.         test    eax,eax
  97.         je      mainf1
  98.         mov     ah,09h                  ; if error initializing,
  99.         lea     edx,[ErrMsg1]           ; print message and exit.
  100.         int     21h
  101.         jmp     maind1
  102.  
  103. ; load RIFF/DSMF module file from disk
  104. mainf1:
  105.         lea     eax,[SongFile]
  106.         call    dLoadModule
  107.         mov     [M],eax
  108.         test    eax,eax                 ; if error loading module file,
  109.         jne     mainf2                  ; print message, deinitialize
  110.         mov     ah,09h                  ; the sound system and exit.
  111.         lea     edx,[ErrMsg2]
  112.         int     21h
  113.         call    dDone
  114.         jmp     maind1
  115.  
  116. ; setup the amount of active voices and the master volume level
  117. mainf2:
  118.         mov     esi,[M]
  119.         movzx   eax,[esi+DSM.Header.NumTracks]
  120.         movzx   edx,[esi+DSM.Header.MasterVolume]
  121.         call    dSetupVoices
  122.  
  123. ; start playing the module file
  124.         mov     eax,[M]
  125.         call    dPlayMusic
  126.  
  127. ; print message and wait for a keypress . . .
  128.         mov     ah,09h
  129.         lea     edx,[OkMsg]
  130.         int     21h
  131. mainl0: call    dPoll                   ; poll the sound system until
  132.         mov     ah,01h                  ; a key is pressed...
  133.         int     16h
  134.         jz      mainl0
  135.  
  136. ; stop playing the music and release the module file from memory
  137.         call    dStopMusic
  138.         mov     eax,[M]
  139.         call    dFreeModule
  140.  
  141. ; shutdown the sound system and exit . . .
  142.         call    dDone
  143.         clc
  144.         jmp     maind0
  145. maind1: stc
  146. maind0: popad
  147.         sbb     eax,eax                 ; return zero on success...
  148.         ret
  149. endp
  150.  
  151. end
  152.