1d07 ;; Direct mode transfer to SB Pro using Timer 0 (INT 8) ;; Maximal transfer speed is 23 KHz for SB Pro in this ;; mode INCLUDE SCREEN.MAC INCLUDE KEYB.MAC INCLUDE CONV.MAC hdr_offset EQU 32 ..286 CSEG SEGMENT ASSUME CS:CSEG,DS:CSEG ORG 100h start: jmp begin ;-------------------------------------------------------------------------- stackspace db 32 dup ('STACK ') newstack dw 0 Org_rutin dd ? voc_stat dw ? smp_size dw ? counter1 dw ? counter2 dw ? voc_off1 dw ? voc_seg1 dw ? voc_off2 dw ? voc_seg2 dw ? kuk db 0 irqmask_save db ? ;------------------------------------------------------------------------ buf_init PROC NEAR mov bp,sp mov dx,word ptr[bp] mov sp,OFFSET newstack ;New stack pointer mov ah,4aH ;Mshrink mov bx,65535/16 ;Bytes left for program int 21H mov ah,48H ;Allocate memory for voice 1 mov bx,65535/16 int 21H mov voc_seg1,ax ;Pointer to allocated segment mov voc_off1,0 mov ah,48h ;Allocate memory for voice 2 mov bx,65535/16 int 21h mov voc_seg2,ax mov voc_off2,0 mov bp,sp mov word ptr[bp],dx ret buf_init ENDP ;---------------------------------------------------------------------------- fn_buf db 80,0 vocname db 80 dup(0) fhandle dw 0 dec_buf db 7 dup(0) sampling dw ? count dw ? read_file PROC NEAR xor cx,cx mov cl,byte ptr ds:[80h] cmp cl,00h jz no_params mov di,81h mov al,' ' repe scasb cmp cx,0 jz no_params dec di mov si,di mov di,OFFSET vocname get_vocname: movsb cmp byte ptr[si],0Dh jz params cmp byte ptr[si],020h jz params jmp get_vocname no_params: Print 'File to play: ' readstr fn_buf mov bp,offset vocname mov si,OFFSET fn_buf+1 ;Remove trailing CR xor dx,dx mov dl,byte ptr[si] mov si,dx mov byte ptr [bp+si],00h params: mov ah,3dh ;Open file mov al,0 mov dx,offset vocname int 21h jc read_error xchg ax,bx push ds mov ds,voc_seg1 ;Change to Buffer Segment mov ah,3fh ;Read file mov cx,65535 mov dx,00h int 21h pop ds dec ax mov smp_size,ax ;Save bytes read in COUNT abort: ret read_error: pushf cr_lf Print 'Error: file not found' cr_lf popf jmp abort read_file ENDP ;------------------------------------------------------------------------ write_dsp PROC NEAR wd10: in al,dx or al,al js wd10 mov al,ah out dx,al ret write_dsp ENDP ;----------------------------------------------------------------------------- reset_card PROC NEAR 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 ret reset_card ENDP ;--------------------------------------------------------------------------- speaker_on PROC NEAR mov dx,22ch mov ah,0d1h call write_dsp ret speaker_on ENDP speaker_off PROC NEAR mov dx,22ch mov ah,0d3h call write_dsp ret speaker_off ENDP ;--------------------------------------------------------------------------- Start_ISR: Our_Layer PROC FAR ASSUME CS:CSEG,DS:CSEG push ds push ax push dx push es push si push cs pop ds add counter1,1 mov dx,counter1 cmp dx,smp_size jle 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 es,voc_seg1 mov si,counter1 mov ah,byte ptr es:[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 Our_Layer ENDP ;======================================================================= play_voice PROC NEAR ASSUME CS:CSEG,DS:CSEG mov counter1,0 mov counter2,0 push cs ;DS m†ste peka p† r„tt segment pop ds ;d† vi skall ladda om vektorn 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 Start_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,39h ;64 = 12 KHz out dx,al ;32 = 23 KHz mov al,00h out dx,al ;----------------------- in al,21h ;Disable all interrupts mov irqmask_save,al ;except system and keyboard (IRQ 0, IRQ 1) mov al,0fch out 21h,al ;------------------------- sti whily: cmp voc_stat,0ffffh jnz whily cli ;------------------------- mov al,irqmask_save ;Enable interrupts out 21h,al ;------------------------ 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 ret play_voice ENDP ;========================================================================= begin: call buf_init call read_file jc abort2 call reset_card call speaker_on call play_voice call speaker_off abort2: mov ax,4c00h int 21h CSEG ENDS END start . 0