'Ladder.bas
'Use inp() and out to play a short ladder of tones on the PC speaker
'Credit goes to Daniel P Hudson for posting a short snippet in Usenet, which
'was modified to make this program.

 Orig(0) = INP(hexdec("43"))
 Orig(1) = INP(hexdec("61"))
 OUT hexdec("43"), hexdec("B6")         ' link timer to freq divisor
 OUT hexdec("42"), 0            ' Set freq for silence
 OUT hexdec("42"), 0            ' No surprise sounds this way.
 OUT hexdec("61"), hexdec("4F")         ' Turn speaker ON

 FOR X = 10000 to 15000
     CALL FREQ X
     time$ = time$()
     'while time$ = time$() : wend
 NEXT X

 OUT hexdec("43"), Orig(0)
 OUT hexdec("61"), Orig(1)
 END

 SUB FREQ F  ' Sets Frequency

  Div = INT(119000 / F)
  lDiv = Div and 255
  hDiv = int(Div / 256)
  OUT hexdec("42"), hDiv
  OUT hexdec("42"), lDiv

 END SUB
