; ----- Sound an 'urgent' alarm
;	R.McG; 5/89, Chicago
; ----------------------------------------------------------------
; Usages:
;	  N0-N5 ---> Destroyed
;
; Requires:
;	  This script does not FCALL any other script
;
; WARNING:
;	  Modify this script at your own RISK!	Playing with machine
;	  level OUTPUT instructions may be dangerous to you and yours.
;
; This script may be FCALLED
; ----------------------------------------------------------------
;	Initialize
;
n2 = 3025		; Start freq	(440hz -> 3025)
N3 = 3025/4		; End freq	(1760hz -> 3025/4)
n4 = 10 		; Step between notes

WOPEN 10,10,12,70 (contrast) Exit
ATSAY 10,12 (contrast) " Urgent "
ATSAY 11,12 (contrast) "Alarm"
ATSAY 12,30 (contrast) " Press ESC to exit "
;
;	Initialize timer
;	.. (0b6H -> counter 2,load 1 byte at a time,square wave, binary values)
;
output 0x43 0xb6	; port = 43h
output 0x42 N2\256	; lsb
output 0x42 N2/256	; msb
;
;	Turn on speaker
;
input n0 0x61		; Get current value
n1 = n0 		; Save value to restore
n0 = n0|3		; Turn on speaker
output 0x61 n0		; Turn speaker on
;
;	Now, run the frequency fron N2 (start) to N3 (end)
;
do
FOR N5 = N2-N4,N3,-N4
    output 0x43 0xb6	; port = 43h
    output 0x42 N5\256	; lsb
    output 0x42 N5/256	; msb
    ENDFOR
until zero -1
;
;	Turn speaker off
;
exit:
output 0x61 n1		; Restore original value
WCLOSE
if fcalled
   freturn
   endif
exit
