		.8086
		
		; .model	large,c
	  
	  	.data
		
		db		256 dup (?)
		
si_stack		label WORD
	
old_sp		dw	?
old_ss		dw	?
		
si_busy		db	0
				db	0
		
		.code
		
		.386
		
		EXTRN		music_poll_ :far
		EXTRN		_mcpPoll :far
		EXTRN		_mcpGetDelta :far
		
		EXTRN		_sound_installed:word
		
		public	sound_interrupt_
		
sound_interrupt_		proc
	
		pushad
		push	ds
		push	es
		
		mov		ax,DGROUP               ; Load data segment value
		mov		ds,ax
		mov		es,ax
		
		cmp		_sound_installed,1
		jne		no_sound_stuff
		
		cmp		si_busy,1
		je			still_busy
		
		mov		si_busy,1
	  
	  	cli
		
		mov		old_ss,ss
		mov		old_sp,sp
		mov		ax,ds
		mov		ss,ax
		mov		sp,offset si_stack
		
		sti
	 
	 	call		music_poll_
	  
		call		_mcpGetDelta
		push		dx
		push		ax
	  	call		_mcpPoll
		add		sp,4
		
		cli
		
		mov		ss,old_ss
		mov		sp,old_sp
		
		mov		si_busy,0
		
		sti
		
no_sound_stuff:

still_busy:

		mov	al,020h
		out	020h,al
		
		in		al,61h
		or		al,080h
		out	061h,al
			  
		pop	es
		pop	ds
		popad

		iret

sound_interrupt_		endp		

		end
