c13 ;CTVOICE.ASM (SOUND.LIB) ; ;Soundblaster-rutiner f”r MASM ; ;Returv„rde fr†n init_ctvoice: AX = 0 vid fel ;Inparameter f”r play_sample: ES:DI = segment:offset samples data-block ;Inparametrar f”r play_xms_sample: DX = XMS-handle f”r sample ; DI:SI = offset i XMS-block (1ah) ; b EQU byte ptr w EQU word ptr INCLUDE DOS.INC INCLUDE BIOS.INC .MODEL SMALL .386 .DATA env_msg db 'Error: SOUND environment variable not found!',13,10,'$' env_var db 'SOUND=' drv_path db 128 dup (0) path_add db '\DRV\CT-VOICE.DRV',0 .DATA? envseg dw ? ct_addr dd ? handle dw ? fsize dw ? PUBLIC ctvoice_status ctvoice_status dw ? .CODE PUBLIC init_ctvoice PUBLIC exit_ctvoice PUBLIC play_sample PUBLIC play_xms_sample PUBLIC stop_sample play_sample PROC mov bx,6 call ct_addr ret play_sample ENDP play_xms_sample PROC mov bx,14 call ct_addr ret play_xms_sample ENDP stop_sample PROC mov bx,8 call ct_addr ret stop_sample ENDP init_ctvoice PROC mov dx,offset path_add+5 ;First check if the driver @OpenFile dx,0 ;exists in the current dir jnc opn_ok call get_env jnc env_found mov ah,9 mov dx,offset env_msg int 21h jmp abort env_found: mov dx,offset drv_path @OpenFile dx,0 jc abort opn_ok: mov handle,ax @GetFileSize handle mov fsize,ax add ax,15 shr ax,4 @GetBlock ax jc abort mov word ptr[ct_addr+2],ax mov word ptr[ct_addr],0 push ds @Read 0,fsize,handle,word ptr[ct_addr+2] pop ds @CloseFile handle mov bx,3 ;initialize driver call ct_addr mov ax,ds mov es,ax mov di,offset ctvoice_status mov bx,5 call ct_addr mov ax,1 jmp no_err abort: mov ax,0 no_err: ret init_ctvoice ENDP exit_ctvoice PROC mov bx,9 call ct_addr mov es,word ptr[ct_addr+2] @FreeBlock ret exit_ctvoice ENDP get_env PROC mov ah,51h ;get PSP address int 21h mov es,bx mov dx,es:[2ch] ;get segment address of environment mov envseg,dx mov si,offset env_var mov es,envseg mov di,0 mov al,0 ; used in SCASB one_more: mov si,offset env_var mov cx,6 repe cmpsb jz getpath ; If match, retrieve path mov cx,0ffffh ; Find end of variable repne scasb cmp b es:[di],0 ; End of Environment string? jnz one_more ; No, check the variable stc ;Carry set = not found ret getpath: ; Get SOUND path mov dx,ds mov es,dx mov si,di mov di,offset drv_path push ds mov ds,envseg getlp: movsb cmp byte ptr ds:[si],0 jnz getlp cmp byte ptr ds:[si-1],'\' jnz no_trailslash dec di no_trailslash: pop ds mov si,offset path_add mov cx,18 ;Add the rest of the CT-VOICE path rep movsb clc ret get_env ENDP END . 0