12be DOSSEG .MODEL SMALL .386 .STACK .DATA EXTRN _sampbuf:PTR BYTE EXTRN _bufsize:WORD Org_Rutin dd ? counter dw ? voc_stat dw ? .CODE PUBLIC _rec PUBLIC _play PUBLIC _reset_card PUBLIC _spkr_on PUBLIC _spkr_off write_dsp PROC wd10: in al,dx or al,al js wd10 mov al,ah out dx,al ret write_dsp ENDP _reset_card PROC push cx push dx mov dx,226h mov al,1 out dx,al mov cx,0ffh del:loop del mov al,0 out dx,al mov dx,22eh poll: in al,dx ;Check for data available or al,al jns poll mov dx,22ah in al,dx ;Check for ready byte cmp al,0aah jnz poll pop dx pop cx ret _reset_card ENDP ;--------------------------------------------------------------------------- _spkr_on PROC push dx mov dx,22ch mov ah,0d1h call write_dsp pop dx ret _spkr_on ENDP _spkr_off PROC push dx mov dx,22ch mov ah,0d3h call write_dsp pop dx ret _spkr_off ENDP ;--------------------------------------------------------------------------- Play_ISR PROC FAR ASSUME CS:_TEXT,DS:@data push ds push ax push dx push es push si mov ax,@data mov ds,ax add counter,1 mov dx,counter cmp dx,_bufsize jbe not_ready mov voc_stat,0ffffh jmp end_of_ISR not_ready: mov dx,22ch wd1: in al,dx or al,al js wd1 mov al,10h out dx,al mov si,word ptr[_sampbuf] add si,counter mov ah,byte ptr[si] wd2: in al,dx or al,al js wd2 mov al,ah out dx,al end_of_ISR: mov al,20h ;Signal End of Interrupt out 20h,al pop si pop es pop dx pop ax pop ds iret Play_ISR ENDP Rec_ISR PROC FAR ASSUME CS:_TEXT,DS:@data push ds push ax push dx push es push si mov ax,@data mov ds,ax add counter,1 mov dx,counter cmp dx,_bufsize jbe not_ready2 mov voc_stat,0ffffh jmp end_of_RecISR not_ready2: mov dx,22ch wd3: in al,dx or al,al js wd3 mov al,20h out dx,al mov dx,22eh wd4: in al,dx or al,al jns wd4 mov dx,22ah in al,dx mov si,word ptr[_sampbuf] add si,counter mov byte ptr[si],al end_of_RecISR: mov al,20h ;Signal End of Interrupt out 20h,al pop si pop es pop dx pop ax pop ds iret Rec_ISR ENDP ;======================================================================= _play PROC push dx push es push si push di mov counter,0 mov voc_stat,0 mov al,08h ;H„mta vektorn till INT 08h mov ah,35h int 21h mov word ptr[Org_Rutin],bx ;Org_Rutinens OFFSET h„mtas mov word ptr[Org_Rutin+2],es ;Segment sparas cli ;Fixa till ISR mov ax,0 mov es,ax mov di,20h mov ax,OFFSET Play_ISR stosw mov ax,cs stosw mov dx,43h ;Programmera om Timer 0 mov al,36h out dx,al mov dx,40h mov al,6ch out dx,al mov al,00h out dx,al sti whily: mov ah,1 int 16h jnz kuk cmp voc_stat,0ffffh jnz whily kuk: cli mov dx,43h mov al,36h out dx,al mov dx,40h ;¸terst„ll divisor f”r Timer 0 mov al,0ffh out dx,al mov al,0ffh out dx,al mov ax,0 ;Restore INT 8 mov es,ax mov di,20h mov ax,word ptr[Org_Rutin] stosw mov ax,word ptr[Org_Rutin+2] stosw sti pop di pop si pop es pop dx ret _play ENDP _rec PROC push dx push es push si push di mov counter,0 mov voc_stat,0 mov al,08h ;H„mta vektorn till INT 08h mov ah,35h int 21h mov word ptr[Org_Rutin],bx ;Org_Rutinens OFFSET h„mtas mov word ptr[Org_Rutin+2],es ;Segment sparas cli ;Fixa till ISR mov ax,0 mov es,ax mov di,20h mov ax,OFFSET Rec_ISR stosw mov ax,cs stosw mov dx,43h ;Programmera om Timer 0 mov al,36h out dx,al mov dx,40h ;Ny divisor mov al,6ch out dx,al mov al,00h out dx,al sti whily2: mov ah,1 int 16h jnz kuk2 cmp voc_stat,0ffffh jnz whily2 kuk2: cli mov dx,43h mov al,36h out dx,al mov dx,40h ;¸terst„ll divisor f”r Timer 0 mov al,0ffh out dx,al mov al,0ffh out dx,al mov ax,0 ;Restore INT 8 mov es,ax mov di,20h mov ax,word ptr[Org_Rutin] stosw mov ax,word ptr[Org_Rutin+2] stosw sti pop di pop si pop es pop dx ret _rec ENDP END . 0