home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / CDMP16.ZIP / SOURCE.ZIP / APLAY.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-02-27  |  2.9 KB  |  87 lines

  1. ;[]------------------------------------------------------------------------[]
  2. ;|                                                                          |
  3. ;| (c) 1993,1994 by Marc van Shaney , aka Kaya Memisoglu                    |
  4. ;|                                                                          |
  5. ;| Dieser Assembler-Source-Code unterliegt dem Urheberrecht von Kaya        |
  6. ;| Memisoglu und darf auch nur mit seiner schriftlichen Genehmigung         |
  7. ;| in kommerziellen Programmen verwendet werden.                            |
  8. ;| Ich übernehme keinerlei Verantwortung für eventuelle Schäden,die dieses  |
  9. ;| Programm verursacht.                                                     |
  10. ;|                                                                          |
  11. ;|                                                                          |
  12. ;| 18.12.1994 Kaya Memisoglu                                                |
  13. ;|                                                                          |
  14. ;[]------------------------------------------------------------------------[]
  15. ;
  16. ;[]------------------------------------------------------------------------[]
  17. ;|
  18. ;| This is the ASM-example for CDMI. It simply loads DEMO.MOD and starts
  19. ;| to play this module through the PC-Loudspeaker.
  20. ;|
  21. ;| You must link this module with CDMI.OBJ, EXT386.OBJ and SPEAKER.ASM
  22. ;|
  23.  
  24.  
  25. P386
  26. LOCALS
  27. JUMPS
  28. .MODEL USE16 LARGE
  29. STACK        200h            ;512 bytes stack shopuld be enough
  30.  
  31.  
  32. include ext386.inc
  33. include cdmi.inc
  34. include devices.inc
  35. include keys.inc
  36.  
  37. ;This macro shrinks the allocated memory to the size really needed by the
  38. ;program, because DOS allocates the WHOLE memory when loading an EXE prog.
  39. ;This naturally is not usable if you want to allocate some DOS-Heap.
  40. ;(This macro is from EXEPROG.ASM by Borland Inc.)
  41. SHRINK_MEM MACRO
  42.    MOV BX,SP
  43.    ADD BX,15    ;convert SP into paragraphs
  44.    SHR BX,4
  45.    MOV AX,SS    ;calculate size of program using ES PSP address
  46.    ADD BX,AX
  47.    MOV AX,ES
  48.    SUB BX,AX
  49.    MOV AH,4AH   ;resize memory block with PSP
  50.    INT 21H      ;address in ES
  51.    ENDM
  52.  
  53.  
  54.  
  55. .Code
  56. Device_Ptr    dd    ?
  57. FName        db    "DEMO.MOD",0
  58.  
  59.  
  60. main PROC FAR
  61.     .STARTUP
  62.     SHRINK_MEM
  63.     mov eax,DISPLAY_INFO or EXIT_ON_LOWMEM or EXIT_ON_RESET or VERBOSE_PAUSE
  64.     call Init_EXT386 C,4096,eax
  65.     mov bx,SEG SPEAKER_Driver
  66.     mov es,bx
  67.     mov ebx,es:[OFFSET SPEAKER_Driver]    ;Get PC-Speaker device
  68.     mov cs:[Device_Ptr],ebx            ;Ptr to device-header
  69.     mov ax,SEG CDMI_DMA_Address
  70.     mov ds,ax
  71.     les di,cs:[Device_Ptr]
  72.     call dword ptr es:[di+DRV_INIT]        ;Init device (IMPORTANT !)
  73.     call CDMI_Load_MOD C,OFFSET FName,cs
  74.     call CDMI_Play_Song C,22000,LOOP_FLAG,dword ptr cs:[Device_Ptr]
  75.  
  76.  @@1:    GETKEY
  77.     test ax,ax
  78.     jz @@1
  79.  
  80.     call CDMI_Stop_Song
  81.     call CDMI_Free_Song
  82.     les di,cs:[Device_Ptr]
  83.     call dword ptr es:[di+DRV_EXIT]        ;DeInit device (IMPORTANT !)
  84.     call Exit_EXT386
  85.     .EXIT
  86. main ENDP
  87. END