jz get_keyinput_to_1 ;branch if sound off
mov cx,sound_time_m ;else check for sound update
mov ax,sound_time_l
call test_current_time
jc get_keyinput_to_1 ;branch if not ready for update
mov bx,sound_table
mov ax,[bx]
or ax,ax ;test for end of table
jz turn_sound_off_to ;branch if end of table data
call get_time_plus_ax
mov sound_time_m,cx
mov sound_time_l,ax
inc bx
inc bx
mov ax,[bx]
inc bx
inc bx
mov sound_table,bx
call sound_out_ax
jmp get_keyinput_to_1
turn_sound_off_to:
call sound_off
mov sound_flag,0
jmp get_keyinput_to_1
get_keyinput_to endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************ @@@@@@@@@@ ************
;### code entry point #####
start_table_sound proc near
;subroutine to start background sound output
;on entry BX indexes sound data table
public start_table_sound
push ax
push bx
mov ax,[bx]
call get_time_plus_ax
mov sound_time_m,cx
mov sound_time_l,ax
inc bx
inc bx
mov ax,[bx]
inc bx
inc bx
mov sound_table,bx
call sound_out_ax
mov sound_flag,0FFH
pop bx
pop ax
ret
start_table_sound endp
;************ ========== *************
;### code entry point #####
flush_keyboard proc near
;utility to flush contents of keyboard buffer
public flush_keyboard
mov ah,1
int 16H ;BIOS Call ;scan for keyboard data
jz flush_keyboard_x ;branch if no keyboard data
mov ah,0 ;else get keyboard data
int 16H ;BIOS Call
jmp flush_keyboard
flush_keyboard_x:
ret
flush_keyboard endp
;************* ----------- **************
sound_out_ax proc near
;set sound out frequency to data value in AX
push ax
push ax
cmp sound_on_flag,0
jne sound_out_1
in al,61H ;input port 61h
or al,3
out 61H,al ;output port 61h
sound_out_1:
mov al,0B6H
out 43H,al ;output port 43h
pop ax
out 42H,al ;output port 42h
xchg al,ah
out 42H,al ;output port 42h
mov sound_on_flag,0FFH
pop ax
ret
sound_out_ax endp
;*********** $$$$$$$$$$ ************
;###### code entry point #######
sound_off proc near
;turn sound port off