home *** CD-ROM | disk | FTP | other *** search
-
- ' Sound statement include program. Use:
- ' $include "Sound.inc"
- ' to include the normal basica SOUND statement
-
- ' Return the current value of the timer counter in bios
- Def TimerVal%()
- Def Seg=&h40
- TimerVal%=Peek(&h6c)+(Peek(&h6d) shl 8)
- End Def
-
- ' Do a sound for a specified length of time
- ' Enter:
- ' Freq! is the frequency
- ' Dur is the duration in clock ticks
- sub sound freq!,dur%
- Static SndInit%
- Local Tone%
- If SndInit%=0 then ' First time through
- Out &h43,&hb6
- SndInit%=1 ' Reset flag
- End If
- If (Freq!<40) then Freq!=40 ' Lowest tone possible
- ' Compute Tone% value from frequency
- Tone%=(1193182/Freq!)
- ' Now set the tone
- Out &h42,Tone% and &hff ' Low byte
- Out &h42,Tone% shr 8 ' high byte
- ' Turn tone on
- Out &h61,Inp(&h61) or 3
- ' Wait for duration
- DesiredVal%=TimerVal%()+Dur%
- While DesiredVal%>TimerVal%()
- Wend
- ' Turn tone off
- Out &h61,Inp(&h61) and &hfc
- End Sub
-