jz sound_update
mov ah,0 ;set AH for get key
int 16H ;BIOS Call
pop dx
pop cx
pop bx
ret
;******* -------- *******
sound_update:
cmp sound_flag,0 ;check for sound on????
jz get_keyinput_loop ;branch out if sound off
mov cx,sound_time_m ;else check for sound update
mov ax,sound_time_l
call test_current_time ;is it time for update ??
jc get_keyinput_loop ;branch if not time
mov bx,sound_table
mov ax,[bx] ;get next sound update value
or ax,ax ;?? end of sound ??
jz turn_sound_off ;branch if end sound
call get_time_plus_ax ;reset sound duration
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 ;go set sound frequency
jmp get_keyinput_loop ;branch to keyboard loop
turn_sound_off:
call sound_off
mov sound_flag,0
jmp get_keyinput_loop ;branch to keyboard loop
get_keyinput endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************ ########## *************
;### code entry point #####
get_keyinput_to proc near
;get keyboard data with timeout if no data available
;on entry AX has time duration in 18 ticks per second
;on exit if carry clear then AX has keyboard data
public get_keyinput_to
push bx
push cx
push dx
call get_time_plus_ax ;add duration to current time
mov key_time_out_m,cx ;set timeout value
mov key_time_out_l,ax
get_keyinput_to_loop:
mov ah,1 ;ready to scan keyboard data
int 16H ;BIOS Call
jz sound_update_to ;branch if no keyboard data
mov ah,0 ;ready to get key data
int 16H ;BIOS Call
pop dx
pop cx
pop bx
clc ;set keyboard data flag
ret
get_keyinput_to_1:
mov cx,key_time_out_m ;check for timeout
mov ax,key_time_out_l
call test_current_time
jc get_keyinput_to_loop ;branch if no timeout
xor ax,ax ;else timeout return condition
pop dx
pop cx
pop bx
stc ;set no keyboard data flag
ret
; ******** %%%%%%% ********
sound_update_to:
cmp sound_flag,0 ;check for sound on????