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 >
Wrap
Assembly Source File
|
1995-04-10
|
5KB
|
152 lines
;/***************************************************************************
;*
;* Digital Sound Interface Kit (DSIK)
;* Version 2.00
;*
;* by Carlos Hasan
;*
;* Filename: example12.asm
;* Version: Revision 1.0
;*
;* Language: Turbo Assembler 4.0 (Ideal Mode)
;* Environment: IBM PC (DOS/4GW)
;*
;* Description: Play a music module file. This is just a simple assembly
;* example to show how to interface with the sound system
;* from an assembly language program.
;*
;* NOTE: If you do not use TASM ideal mode, the AUDIO.INC file
;* and this example file are not very useful. If you want
;* to compile this example, type at the DOS prompt:
;* tasm -m -q -ml -p -t -i..\include examp12.asm
;* wcl386 -zq -l=dos4g -"libpath ..\lib" examp12.obj
;*
;***************************************************************************/
ideal
p386
model flat,c
include "audio.inc"
; link the WATCOM C run-time library (register calling convention library)
includelib "clib3r.lib"
;[]------------------------------------------------------------------------[]
; If you do not want to link the C run-time library in your 100% assembly
; programs you have two alternatives:
; a) Rewrite the highlevel MODLOAD.C routines in assembly language, or
; b) Rewrite the run-time routines used in the MODLOAD.C source file.
; However, if you do not link the C run-time library the DOS/4GW v1.95 (and
; above) 32-bit DOS extender won't execute your programs, because your
; program won't be recognized like a WATCOM application. You can use DOS/4G
; or PMODE/W DOS extenders for your 100% assembly programs.
;[]------------------------------------------------------------------------[]
dataseg
ErrMsg0 db 'Please run SETUP.EXE to configure.',10,13,'$'
ErrMsg1 db 'Error initializing the sound system.',10,13,'$'
ErrMsg2 db 'Error loading SONG.DSM module file.',10,13,'$'
OkMsg db 'Playing module. Press any key to continue.',10,13,'$'
SetupFile db 'SETUP.CFG',0 ; setup filename
SongFile db 'SONG.DSM',0 ; module filename
udataseg
SC SoundCard ? ; soundcard structure
M dd ? ; module pointer
codeseg
;/***************************************************************************
;*
;* Function: main_
;* Parameters: EAX - number of arguments
;* EDX - arguments vector
;*
;* Returns: Return zero on success.
;*
;* Description: Main routine called by the WATCOM run-time code.
;*
;***************************************************************************/
global nolanguage main_:proc
proc main_ nolanguage
pushad
; first register all the audio drivers using the dRegisterDrivers macro.
dRegisterDrivers
; load the setup configuration file from disk
lea eax,[SC]
lea edx,[SetupFile]
call dLoadSetup
test eax,eax
je mainf0
mov ah,09h ; if error loading the file,
lea edx,[ErrMsg0] ; print message and exit.
int 21h
jmp maind1
; initialize the DSIK 2.0 sound system . . .
mainf0:
lea eax,[SC]
call dInit
test eax,eax
je mainf1
mov ah,09h ; if error initializing,
lea edx,[ErrMsg1] ; print message and exit.
int 21h
jmp maind1
; load RIFF/DSMF module file from disk
mainf1:
lea eax,[SongFile]
call dLoadModule
mov [M],eax
test eax,eax ; if error loading module file,
jne mainf2 ; print message, deinitialize
mov ah,09h ; the sound system and exit.
lea edx,[ErrMsg2]
int 21h
call dDone
jmp maind1
; setup the amount of active voices and the master volume level
mainf2:
mov esi,[M]
movzx eax,[esi+DSM.Header.NumTracks]
movzx edx,[esi+DSM.Header.MasterVolume]
call dSetupVoices
; start playing the module file
mov eax,[M]
call dPlayMusic
; print message and wait for a keypress . . .
mov ah,09h
lea edx,[OkMsg]
int 21h
mainl0: call dPoll ; poll the sound system until
mov ah,01h ; a key is pressed...
int 16h
jz mainl0
; stop playing the music and release the module file from memory
call dStopMusic
mov eax,[M]
call dFreeModule
; shutdown the sound system and exit . . .
call dDone
clc
jmp maind0
maind1: stc
maind0: popad
sbb eax,eax ; return zero on success...
ret
endp
end