< -->
;wavdir.asm
FILESPEC equ "C:\D_TEMPOS\ASM\tada.wav"
SBPORT equ 220h
.model tiny
.code
.186
org 100h
start:
call dsp_reset
jc no_blaster
mov bl, 0D1h
call dsp_write
call open_file
call hook_int8
mov bx, 5
call reprogram_pit
main_loop:
cmp byte ptr finished_flag, 0
je main_loop
mov bx, 0FFFFh
call reprogram_pit
call restore_int8
no_blaster:
ret
buffer_addr dw offset buffer
old_int08h dd ?
finished_flag db 0
filename db FILESPEC, 0
int08h_handler proc far
pusha
cmp byte ptr cs:finished_flag, 1
je exit_handler
mov di, word ptr cs:buffer_addr
mov bl, 10h
call dsp_write
mov bl, byte ptr cs:[di]
call dsp_write
inc di
cmp di, offset buffer+27459
jb not_finished
mov byte ptr cs:finished_flag, 1
not_finished:
mov word ptr cs:buffer_addr, di
exit_handler:
mov al, 20h
out 20h, al
popa
iret
int08h_handler endp
dsp_reset proc near
mov dx, SBPORT+6
mov al, 1
out dx, al
mov cx, 40
dsploop:
in al, dx
loop dsploop
mov al, 0
out dx, al
add dx, 8
mov cx, 100
check_port:
in al, dx
and al, 80h
jz port_not_ready
sub dx, 4
in al, dx
add dx, 4
cmp al, 0AAh
je good_reset
port_not_ready:
loop check_port
bad_reset:
stc
ret
good_reset:
clc
ret
dsp_reset endp
dsp_write proc near
mov dx, SBPORT+0Ch
write_loop:
in al, dx
and al, 80h
jnz write_loop
mov al, bl
out dx, al
ret
dsp_write endp
reprogram_pit proc near
cli
mov al, 00110110b
out 43h, al
mov al, bl
out 40h, al
mov al, bh
out 40h, al
sti
ret
reprogram_pit endp
hook_int8 proc near
mov ax, 3508h
int 21h
mov word ptr old_int08h, bx
mov word ptr old_int08h+2, es
mov ax, 2508h
mov dx, offset int08h_handler
int 21h
ret
hook_int8 endp
restore_int8 proc near
mov ax, 2508h
lds dx, dword ptr old_int08h
int 21h
ret
restore_int8 endp
open_file proc near
mov ax, 3D00h
mov dx, offset filename
int 21h
jc error_exit
mov bx, ax
mov ax, 4200h
mov cx, 0
mov dx, 38h
int 21h
mov ah, 3Fh
mov cx, 27459
mov dx, offset buffer
int 21h
ret
error_exit:
mov ah, 9
mov dx, offset notopenmsg
int 21h
int 20h
notopenmsg db "Ошибка при открытии файла", 0Dh, 0Ah, '$'
open_file endp
buffer:
end start
Назад