💾 Archived View for gemini.spam.works › mirrors › textfiles › phreak › BOXES › jolly2.box captured on 2022-06-12 at 17:18:44.

View Raw

More Information

-=-=-=-=-=-=-

; The Jolly-Box v3.9 (1 Mbit Samplerom, 4 Kb Program ROM).
; New modifications by Zaphod Beeblebrox of Control Team, Origial
; Code by Jolly Roger/Int. Tollfree Access
; Multi-Frequenz-Demon-Dialer for Global Access!!!
; last update 08.May.1993 17:00.26
; code for INTEL 8049 with 10 Mhz (because timing)

;How to Operate:
;===============
;
;Press *0 for samplebank 0 select (DTMF, All 16 Digits).
;Press *1 for samplebank 1 select (CCITT #5 -R1- *DEFAULT*).
;Press *2 for samplebank 2 select (CCITT #5 -R2-).
;Press *3 for samplebank 3 select (Break/Simulation Tones).
;Press *4 for CCITT #4 (2040 Hz/2400 Hz a.k.a 2VF). (Not yet Implemented!)
;Press *# for special tone simulation mode.
;Press **0 to enter a new routing code. The default is KP2+46.
;Press **1 to enter RAM memory number #1.
;Press **2 to enter RAM memory number #2.
;# ends the input and adds ST code if not in DTMF mode.
;
;When entering a number on the input line, the first digit must be
;between 0-3: A "0" means that the prefix in ram should be dialed before
;the actual number you enter. "1" means that KP1 should be the first tone
;dialed when the macro is played back. "2" is the same, but KP2 instead of
;KP1. A ST code is always added at the end of a CCITT number stored in RAM
;or ROM when it's played back. "3" means that this tone should be ignored
;and the rest of the dialing should be done in DTMF mode.
;
;Press 0 to dial the entered number #1. (without trunk)
;Press 1 to dial the entered number #2. (without trunk)
;Press 20-27 for dial in the first phonebook
;Press 30-37 for dial in the second phonebook
;Press 4 for 1850 Hz DHLS tone
;Press 5 for a Redbox "Dime" Tone
;Press 6 for a Redbox "Quarter" Tone
;Press 7 to send US Local Trunk-Tone (2600 Hz, 1.5 seconds).is KP2-460.
;Press 8 to send CCITT International Trunk #1
;Press 9 to send CCITT International Trunk #2
;Press # to get into whitebox mode, press again to return to bluebox mode.

;Example:
;"b46018262804c"
;Press:* 2 4 6 0 1 8 2 6 2 8 0 4 #
;or   :* 0 1 8 2 6 2 8 0 4 #  (b460 will be added for 0)
;"a08185585636c"
;Press:* 1 0 8 1 8 5 5 8 5 6 3 6 #

;When ist beeps three times:
;Quarz is ok.
;Porcessor is ok.
;All chips on the Sound card are ok.

;Press 1,2,3 or 4  when turning on and you get a test of all tones
;in the sample bank you selected.

;  Register:
;  =========
;  r0 = adress reg #1. (Input-Line & Dialing Loops).
;  r1 = adress reg #2. (Prefix-Dialing Loop).
;  r2 = counter for wait routine
;  r3 = sound to play
;  r4 = sound pause
;  r5 = sample bank for autodialing
;  r6 = sound length
;  r7 = temporary register
; r31 = security code entered status
; r32-65 = memory for entered number #1 (ends with 32)
; r66-99 = memory for entered number #2 (ends with 32)
; r100-127 = memory for entered dialing prefix (ends with 32)

;codes in the sample rom:
;the 128Kb rom is divided in 32 2048 large blocks

;00 - "0" DTMF touch tones   10 - "0"    CCITT #5 R1
;01 - "1" DTMF touch tones   11 - "1"    CCITT #5 R1
;02 - "2" DTMF touch tones   12 - "2"    CCITT #5 R1
;03 - "3" DTMF touch tones   13 - "3"    CCITT #5 R1
;04 - "4" DTMF touch tones   14 - "4"    CCITT #5 R1
;05 - "5" DTMF touch tones   15 - "5"    CCITT #5 R1
;06 - "6" DTMF touch tones   16 - "6"    CCITT #5 R1
;07 - "7" DTMF touch tones   17 - "7"    CCITT #5 R1
;08 - "8" DTMF touch tones   18 - "8"    CCITT #5 R1
;09 - "9" DTMF touch tones   19 - "9"    CCITT #5 R1
;0a - "*" DTMF touch tones   1a - "kp1"  CCITT #5 R1
;0b - "#" DTMF touch tones   1b - "kp2"  CCITT #5 R1
;0c - "a" DTMF touch tones   1c - "st"   CCITT #5 R1
;0d - "b" DTMF touch tones   1d - "C.11" CCITT #5 R1
;0e - "c" DTMF touch tones   1e - "C.12" CCITT #5 R1
;0f - "d" DTMF touch tones   1f - "DHLS" CCITT #5 R1/R2

;20 - "0"    CCITT #5 R2     30 - 2400/2600 Hz
;21 - "1"    CCITT #5 R2     31 - 2400/2400 Hz
;22 - "2"    CCITT #5 R2     32 - 2040/2040 Hz
;23 - "3"    CCITT #5 R2     33 - 2040/2400 Hz
;24 - "4"    CCITT #5 R2     34 - 2280/2280 Hz
;25 - "5"    CCITT #5 R2     35 - 2600/2600 Hz
;26 - "6"    CCITT #5 R2     36 - Spare 1
;27 - "7"    CCITT #5 R2     37 - Spare 2
;28 - "8"    CCITT #5 R2     38 - Spare 3
;29 - "9"    CCITT #5 R2     39 - 480/620 Hz (US Ringing Tone)
;2a - "kp1"  CCITT #5 R2     3a - 350/440 Hz (US Dialtone)
;2b - "kp2"  CCITT #5 R2     3b - 440/480 Hz (US Busy)
;2c - "st"   CCITT #5 R2     3c - 440/440 Hz (Sw. Dialt & Busy).
;2d - "C.11" CCITT #5 R2     3d - 460/460 Hz (German Tone).
;2e - "C.12" CCITT #5 R2     3e - 1700/2200 Hz (US/DK Redbox)                 
;2f - "DHLS" CCITT #5 R2     3f - Silence (Empty!!!).

;port1:	bit  0   = Samplebank Select Low Bit
;	bit  1   = Samplebank Select High Bit
;	bits 2-7 = Rows for keyboard
;port2: bits 0-3 = Program Address Memory High Address Bits
;	bits 4-7 = select a sample of the sample rom (CCITT or DTMF)

;BEGIN OF PAGE $000

;Resetroutine:
	nop			;	lo
	nop			;	hi-pointer to reset ($000)
	nop			;	lo
	nop			;	hi-pointer to nmi ($000)
	nop
	nop
	nop
	nop
	nop

	call	init

;give ok status (beep ,delay 300ms, beep, delay 100ms,long beep)
;end of reset routine

wboxb:	mov	r4,=75		; 150 ms delay
	call	beep		; beep to show reset
	mov	r4,=25		; set 50 ms delay
	call	beep		; beep again
	call	beep		; a third beep!

;select tone 0, sample-bank 1.

	mov	r3,=%00000000
	mov	r5,=%00000001

;MainMenu
;========
;**0 = enter routing code
;**1 = enter number #1
;**2 = enter number #2
;*0 = select sample bank 0 (DTMF Whitebox, all 16 tones).
;*1 = select sample bank 1 (CCITT #5 R1 Tones).
;*2 = select sample bank 2 (CCITT #5 R2 Tones).
;*3 = select sample bank 3 (Various Tones/Breaks).
;*4 = select CCITT #4 mode
;*# = special tone simulation mode
;0 = dial entered number #1
;1 = dial entered number #2
;20-17, 30-37 phonebook(s)
;4 = DHLS tone
;5 = Redbox - Dime Tone
;6 = Redbox - Quarter Tone
;7 = Local Trunk, 1.0s 2600 Hz
;8 = CCITT Clear Forward
;9 = CCITT Xfer Forward
;# = whitebox, press again to go back to bluebox.

start:	mov	r4,=0
	call	beep		; beep again
	mov	A,r5
	jz	main
	anl	A,=%00000100
	jz	main
	jmp	c4_main

main:	call	key		; get a code from key Accu
	jz	dial1		; if it is 0 goto dial
	anl	A,=%10111111	; %x0xxxxxx
	jz	command		; if it is 64 command menu 2
	anl	A,=%01111111	; %00xxxxxx
	jz	whitebox	; if it is 128 goto wb
	dec	a		; so it has to be 1-9
	jz	dial2		; if it is 1
	dec	a		; so it has to be 2-9
	jz	dialn1		; if it is 2
	dec	a		; so it has to be 3-9
	jz	dialn2		; if it is 3
	dec	a		; so it has to be 4-9
	jz	dhls		; if it is 4
	dec	a		; so it has to be 5-9
	jz	dime		; if it is 5
	dec	a		; so it has to be 6-9
	jz	quart		; if it is 6
	dec	a		; so it has to be 7-9
	jz	ltrunk		; if it is 7
	dec	a		; so it has to be 8,9
	jz	trunk1		; if it is 8
	jmp	trunk2		; so it had to be 9

;Input line
;Press 0-9 to enter a number.
;Use * to enter special tones (1-6 = A-E, H).
;Use # to finish and add ST code.

enter_r:mov	r0,=100		; set start for routing code
	mov	@r0,=32		; give end code
	jmp	enterl		; goto enterl

enter_1:mov	r0,=32		; set start for number #1 - 32
	mov	@r0,=32		; give end code
	jmp	enterl

enter_2:mov	r0,=66		; set start for number #1 - 32
	mov	@r0,=32		; give end code
	jmp	enterl


dialn1:	mov	A,r5
	mov	r7,A
	call	key		; get a key 0-7
	anl	A,=7		; %00000111
	jmp	dialn		; goto dial

dialn2:	mov	A,r5
	mov	r7,A
	call	key		; get a key 8-15 (0-7)
	orl	A,=8		; %00001000

;dial a number from p3 rom out of

dialn:	mov	r6,=27		; 54 ms tone
	mov	r4,=20		; 40 ms pause
	swap	A		; a=a*16
	mov	r0,a		; put number to r0
	mov	a,r0		; get number from r0
	movp3	a,@A		; hole ersten wert
	inc	r0		; increment position in rom
	jz	route1		; when 0 then dial prefix
	dec	a
	mov	r3,=10		; Sample pointer --> KP1
	jz	touchn		; If 1 - Dial KP1+Number
	dec	a
	mov	r3,=11		; Sample pointer --> KP2
	jz	touchn		; If 2 - Dial KP2+Number
	dec	a
	jnz	main		; If 3 - Dial in DTMF, else go main.
	mov	r4,=40		; 80 ms pause between DTMF's
	mov	r6,=40		; 80 ms duration for DTMF's.
	mov	A,=0
	mov	r5,A		; Select DTMF Sample-Bank
	jmp	rbackn

touchn:	call	sound		; Play the sample
rbackn:	mov	a,r0		; get position in rom
	movp3	a,@A		; Fetch next tone
	inc	r0		; increment position in rom
	mov	r3,a		; put next sample in r3
	jz	touchn		; 0 is also a tone we should output!
	anl	A,=%11011111	; If it's $20 - End of signalling!
	jz	etouch		; We have to check if we should play ST code now...
	jmp	touchn

;dial a number from ram (r32 or r66).

dial1:	mov	r0,=32		; Dial RAM Macro #1
	jmp	dial

dial2:	mov	r0,=66		; Dial RAM Macro #2

dial:	mov	r6,=27
	mov	r4,=20
	mov	A,r5
	mov	r7,A
	mov	a,@r0		; hole ersten wert
	inc	r0		; increment position in ram
	jz	route2		; If 0 - Dial Routing
	mov	r3,=10		; Sample pointer --> KP1
	dec	a
	jz	touch		; If 1 - Dial KP1+Number
	dec	a
	mov	r3,=11		; Sample Pointer --> KP2
	jz	touch		; If 2 - Dial KP2+Number
	dec	a
	jnz	main		; If 3 - Dial in DTMF, else go main.
	mov	r4,=40		; 80 ms pause between DTMF's
	mov	r6,=40		; 80 ms duration of DTMF's
	mov	A,=0
	mov	r5,A
	jmp	rback

touch:	call	sound		; play the sample
rback:	mov	a,@r0		; fetch the next tone
	inc	r0
	mov	r3,a
	jz	touch		; 0 is also a tone we should play!!
	anl	A,=%11011111	; check for $20 - End of signalling
	jnz	touch		; if no end code, goto output
etouch:	mov	A,r5
	jz	endsig		; Don't add ST code for DTMF mode.
	mov	r3,=12		; Sample pointer --> ST code
	call	sound		; play the sample
endsig: mov	A,r7
	mov	r5,A
	jmp	main		; end to main

silence:mov	A,=%11111111
	outl	p1,A
	mov	A,=$f0
	outl	p2,A
	ret

route1: call	dialr		; and wait
	jmp	rbackn		; end to main

route2:	call	dialr		; and wait
	jmp	rback		; end to main

trunk1:	jmp	trunk1n
trunk2: jmp     trunk2n
ltrunk:	jmp	ltrunkn
dime:	jmp	dime1
quart:	jmp	quart1
dhls:	jmp	dhls2
whitebox:jmp	white
command:jmp	command2

	PAGE	1

;Enter number to ram or select sample bank for bluebox mode.
;Press 0-3 for the different sample-banks, and # to enter
;the special tone simulation mode.

command2:call	key
	jz	bank0		; If it's 0 - Samplebank 0 select.
	anl	A,=%10111111	; If * was pressed check for inputline.
	jz	enterm
	anl	a,=%01111111	; If # was pressed goto simulation mode.
	jz	simtj
	dec	a
	jz	bank1		; If it's 1 - Samplebank 1 select.
	dec	a
	jz	bank2		; If it's 2 - Samplebank 2 select.
	dec	a
	jz	bank3		; If it's 3 - Samplebank 3 select.
	dec	a
	jz	ccitt4		; If it's 4 - CCITT #4 Mode Enable.
	jmp	command2

bank0:	mov	A,=0
	jmp	banks

bank1:	mov	A,=1
	jmp	banks

bank2:	mov	A,=2
	jmp	banks

bank3:	mov	A,=3
	jmp	banks

ccitt4:	mov	A,=4

banks:	mov	r5,A
	mov	r4,=0
	call	beep
	jmp	start

enterm:	call	key
	anl	A,=%00000011
	jz	enterr
	dec	a
	jz	enter1
	jmp	enter2

enterl:	mov	r4,=0
	call	beep		; give message, that * was pushed
	call	beep
notspec:call	key		; get a key
	jz	write		; test 0
	anl	A,=%10111111	; %x0xxxxxx
	jz	special		; * = Enter special tone (1-6 = A-E, H)
	anl	A,=%01111111	; %00xxxxxx
	jz	startj		; test #
write:	mov	@r0,a		; if 0-9, write number
	inc	r0		; go to next
	mov	@r0,=32		; set end
	jmp	enterl		; goto enterl

special:call	key
	anl	A,=%00000111
	jz	notspec
	add	A,=9
	jmp	write

;Whitebox routine
;press keys as log as the tone has to play
;	1=$10	2=$20	3=$30
;	4=$40	5=$50	6=$60
;	7=$70	8=$80	9=$90
;	*=$a0	0=$00	#=$b0
;	A=$c0	B=$d0	C=$e0
;		D=$f0

white:	mov	r4,=10
	mov	r6,=20
	call	beep
	call	beep
	mov	a,=%00000011
	outl	p1,A		; set all rows to output
whitell:call	release
	mov	A,=$f0
	outl	p2,A
whitel:	mov	A,=%11111011	; set bit 2 low
	outl	p1,A
	mov	a,=$10
	jnt0	wkey		; jump if key is pressed ...
	mov	a,=$70		; .....
	jnt1	wkey
	mov	a,=%11110111
	outl	p1,A
	mov	a,=$20
	jnt0	wkey
	mov	a,=$80
	jnt1	wkey
	mov	a,=%11101111
	outl	p1,A
	mov	a,=$30
	jnt0	wkey
	mov	a,=$90
	jnt1	wkey
	mov	a,=%11011111
	outl	p1,A
	mov	a,=$40
	jnt0	wkey
	jnt1	ffake
	mov	a,=%10111111
	outl	p1,A
	mov	a,=$50
	jnt0	wkey
	mov	a,=$00
	jnt1	wkey
	mov	a,=%01111111
	outl	p1,A
	mov	a,=$60
	jnt0	wkey
	jt1	whitel		; start over if no key is pressed
	sel	rb1
	mov	A,r7
	jz	fake2
	jmp	wboxb		; return to main menu.
ffake:	sel	rb1
	mov	A,r7
	jz	fake1
	sel	rb0
	jmp	wkey2j
fake1:	sel	rb0
	mov	A,=$b0
	jmp	wkey
fake2:	sel	rb0
	mov	A,=$a0	
wkey:	outl	p2,A		; set tone
	mov	a,=%00000000	; whitebox tones on
	outl	p1,A
	jmp	whitell

;wait routine for waiting 2*A ms (a=65: 130ms) (set a to 0, to get 512ms delay)
wait:	mov	r2,=166		; set loop of 5+166*8 cycles
wait1:	nop			; delay 1 cycle
	nop			; delay 1 cycle
	nop			; delay 1 cycle
	nop			; delay 1 cycle
	nop			; delay 1 cycle
	nop			; delay 1 cycle
	djnz	r2,wait1	; delay 2 cycles
	dec	a		; after 1 #s, if a>0
	jnz	wait		; goto wait again
	ret			; end of wait

dime1:	mov	A,=2
	mov	r4,=33
	mov	r6,=33
	jmp	red

quart1:	mov	A,=5
	mov	r4,=17
	mov	r6,=17
	jmp	red

wkey2j:	jmp	wkey2
enter1:	jmp	enter_1
enter2:	jmp	enter_2
enterr:	jmp	enter_r
simtj:	jmp	simt
startj:	jmp	start

	PAGE	2

;Enter key
;gives The Code of pressed Key in Accu and waits for key press.
;bevore it waits for releasing the key.
;	1=$01	2=$02	3=$03
;	4=$04	5=$05	6=$06
;	7=$07	8=$08	9=$09
;	*=$40	0=$00	#=$80

key:	call	releaseb
keyl:	mov	a,=%11111011	; set bit 2 low
	outl	p1,A
	mov	a,=1
	jnt0	kkey		; jump if key is pressed ...
	mov	a,=7		; .....
	jnt1	kkey
	mov	a,=%11110111
	outl	p1,A
	mov	a,=2
	jnt0	kkey
	mov	a,=8
	jnt1	kkey
	mov	a,=%11101111
	outl	p1,A
	mov	a,=3
	jnt0	kkey
	mov	a,=9
	jnt1	kkey
	mov	a,=%11011111
	outl	p1,A
	mov	a,=4
	jnt0	kkey
	mov	a,=$40
	jnt1	kkey
	mov	a,=%10111111
	outl	p1,A
	mov	a,=5
	jnt0	kkey
	mov	a,=0
	jnt1	kkey
	mov	a,=%01111111
	outl	p1,A
	mov	a,=6
	jnt0	kkey
	mov	a,=$80
	jnt1	kkey
	jmp	keyl		; start over if no key is pressed
kkey:	ret			; ret acc.

;test release key

releaseb:mov	a,=%00000011
	outl	p1,A		; set all rows to output
release:jnt0	release		; wait until there is no key pressed
	jnt1	release		; (both lines)
	mov	a,=37		; delay 75ms
	call	wait
	jnt0	release		; wait if there is no key pressed
	jnt1	release		; (both lines)
	ret

;make a beep sound with 30ms delay

beep:	mov	r3,=$01		; select sound 01, Bank 3 (good beep sound)
	mov	r6,=15		; 30 ms beep
 	mov	A,r5
	mov	r7,A
	mov	r5,=%00000011	; set sound dma
	call	sound		; and wait
	mov	A,r7
	mov	r5,A
	ret

;Sound routine
;r3 represents the sound which is in the sample rom.
;r4 is the pause after the sound, r5 the sample bank & r6 the length

sound:	mov	A,r3		; get sample to a
	swap	A		; a=a*16
	outl	p2,A		; send sample
	mov	A,r5		; tone bank select
	outl	p1,A
	mov	A,r6		; use R6/2 ms to delay
	call	wait		; wait
	call	silence		; stop sound
	mov	A,r4		; pause
	jz	nowait
	call	wait
nowait:	ret			; end of sound

;dial prefix from ram (r100)

dialr:	mov	r4,=20
	mov	r6,=27
	mov	r1,=100		; start
	mov	a,@r1		; hole ersten wert
	inc	r1		; increment position in ram
	dec	a
	mov	r3,=10
	jz	touchr
	dec	a
	mov	r3,=11
	jz	touchr
	dec	a
	jnz	dialr2
	mov	r4,=40		; 80 ms pause between DTMF's
	mov	r6,=40		; 80 ms duration for DTMF's.
	mov	r5,=0		; Select DTMF Samplebank.
	jmp	touchr2
touchr: call	sound		; send the touchtone
touchr2:mov	a,@r1		; hole n?chsten wert
	inc	r1
	mov	r3,a
	jz	touchr		; gebe null aus
	anl	A,=%11011111	; kein code eingegeben
	jnz	touchr		; if no end code, goto output
dialr2:	ret

wkey2:	call	releaseb
wkey2l:	mov	A,=%11111011
	outl	p1,A
	mov	A,=$a0
	jnt0	wkeyj
	mov	A,=%11110111
	outl	p1,A
	mov	A,=$b0
	jnt0	wkeyj
	mov	A,=%11101111
	outl	p1,A
	mov	A,=$c0
	jnt0	wkeyj
	mov	A,=%11011111
	outl	p1,A
	mov	A,=$d0
	jnt0	wkeyj
	mov	A,=%10111111
	outl	p1,A
	mov	A,=$e0
	jnt0	wkeyj
	mov	A,=%01111111
	outl	p1,A
	mov	A,=$f0
	jt0	wkey2l

wkeyj:	jmp	wkey
whitej:	jmp	whitel


	page	3

; Page 3 contains the 16 stored phonenumber ($300-$3ff).

	page	4


; Special tone simulation mode.
; =============================
;
; 1 = Swedish Dialtone.
; 2 = Swedish Busy Tone.
; 3 = Swedish Ringtone.
; 4 = US Dialtone
; 5 = US Busy Tone.
; 6 = US Ringtone.
; 7 = Swedish All Trunks Busy
; 8 = US All Trunks Busy
; 9 = Greenbox Ringback. (700 & 1700 Hz, 1 sec).
; 0 = Greenbox Coin Return (1100 & 1700 Hz, 1 sec).
; * = 2600 Hz wink (90 ms).
; # = Jump back to main menu.

simt:	mov	a,=%00000011
	outl	p1,A
siml1:	call	release
	mov	A,=$f0
	outl	p2,A
siml2:	mov	A,=%11111011	; 1 - Swedish Dialtone
	outl	p1,A
	mov	a,=$c0
	jnt0	skey
	jnt1	sbusy		; 7 - Swedish Slow-Busy
	mov	A,=%11110111	; 2 - Swedish Busy
	outl	p1,A
	mov	A,=$c0
	jnt0	fbusy
	mov	A,=$b0
	jnt1	fbusy		; 8 - US Fast-Busy
	mov	a,=%11101111	; 3 - Swedish Ringtone
	outl	p1,A
	mov	a,=$c0
	jnt0	ringl
	jnt1	rngbck		; 9 - Greenbox Ringback
	mov	a,=%11011111	; 4 - US Dialtone
	outl	p1,A
	mov	a,=$a0
	jnt0	skey
	jnt1	wink26		; * - 2600 Wink (90 ms).
	mov	a,=%10111111	; 5 - US Busy
	outl	p1,A
	mov	a,=$b0
	jnt0	busy
	jnt1	cretn		; 0 - Greenbox Coin Return
	mov	a,=%01111111	; 6 - US Ringtone
	outl	p1,A
	mov	a,=$90
	jnt0	ringl
	jt1	siml2		; start over if no key is pressed
	jmp	wboxb		; return to main menu.
skey:	outl	p2,A		; set tone
	mov	a,=%00000011	; simulation tones on
	outl	p1,A
	jmp	siml1

busy:	mov	r3,=250
	jmp	busyl
fbusy:	mov	r3,=125
busyl:	outl	p2,A
	mov	r7,A
	mov	A,r3
	call	wait
	mov	A,=$f0
	outl	p2,A
	mov	A,r3
	call	wait
	mov	A,r7
	jnt0	busyl
	jnt1	busyl
	jmp	simt

sbusy:	outl	p2,A
	mov	r7,A
	mov	A,=250
	call	wait
	mov	A,=$f0
	outl	p2,A
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,r7
	jnt0	sbusy
	jnt1	sbusy
	jmp	simt

ringl:	outl	p2,A
	mov	r7,A
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=$f0
	outl	p2,A
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,r7
	jnt0	ringl
	jnt1	ringl
	jmp	simt

wink26:	mov	A,=$50
	outl	p2,A
	mov	A,=45
	call	wait
	mov	A,=$f0
	outl	p2,A
	jmp	simt

cretn:	mov	A,=$c0
	outl	p2,A
	mov	A,=%00000001
	outl	p1,A
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=$f0
	outl	p2,A
	jmp	simt

rngbck:	mov	A,=$a0
	outl	p2,A
	mov	A,=%00000001
	outl	p1,A
	mov	A,=250
	call	wait
	mov	A,=250
	call	wait
	mov	A,=$f0
	outl	p2,A
	jmp	simt

	page	5

c4_main:call	beep
	call	beep
	call	beep
	call	beep
	mov	r5,=1
	jmp	start

	page	6

init:	sel	rb0		; use old register
	orl	p1,=%11111111	; %11111111 all bits for output
	orl	p2,=%11111111	; %11111111 all bits for output

	mov	a,=%11111000
	outl	p1,a		; select 1 key and whitebox-mode
	jnt0	selftest	; if 1 is pressed while turning on goto selftest
	mov	a,=%11110101
	outl	p1,a		; select 2 key and bluebox-mode CCITT #5 R1
	jnt0	selftest	; if 2 is pressed while turning on goto selftest
	mov	a,=%11101110
	outl	p1,a		; select 3 key and bluebox-mode CCITT #5 R2
	jnt0	selftest	; if 3 is pressed while turning on goto selftest
	mov	a,=%11011111
	outl	p1,a		; select 4 key and special signalling tones & trunks.
	jnt0	selftest	; if 4 is pressed while turning on goto selftest

;reset number
	mov	r0,=32
	mov	@r0,=32
	mov	r0,=66
	mov	@r0,=32

;set b460 default to memory
	mov	r0,=100
	mov	@r0,=2		;kp2
	inc	r0		; go to next
	mov	@r0,=4		;4
	inc	r0		; go to next
	mov	@r0,=6		;6
	inc	r0		; go to next
	mov	@r0,=0		;0
	inc	r0		; go to next
	mov	@r0,=32		;end

au_code:sel	rb1		; Power-On Security Access code
	mov	r7,=$ff
	call	key
	jz	c_no
	anl	A,=%11111110	; Digit #1 = 1
	jnz	c_no
	call	key
	jz	c_no
	anl	A,=%11111101	; Digit #2 = 2
	jnz	c_no
	call	key
	jz	c_no
	anl	A,=%11111100	; Digit #3 = 3
	jnz	c_no
	call	key
	jz	c_no
	anl	A,=%11111011	; Digit #4 = 4
	jnz	c_no
	sel	rb0
	ret

c_no:	mov	r7,=$00
	sel	rb0
	jmp	white

;Testmode:  All tones will be played!!!

selftest:mov	r3,a
	clr	a
testloop:
	outl	p2,a		;set tone
	mov	r1,a		;keep it
	mov	a,=250		;0.5 sec delay
	call	wait	
	mov	a,r1		;get it back
	add	a,=%00010000	;next sample
	mov	r1,a		;keep it
	call	silence		;sound off
	mov	a,=30	
	call	wait		;pause 60ms
	mov	a,r3
	outl	p1,a
	mov	a,r1
	jmp	testloop	;loop

trunk1n:mov	r3,=$00		; select sound 00
	mov	r4,=0		; no pause
	mov	A,r5
	mov	r7,A
	mov	r5,=%00000011	; select sample bank 03
	mov	r6,=65		; 130 ms 2400/2600 Hz
	call	sound		; play tone
	mov	A,=250		; 500 ms pause
	call	wait
	mov	A,=250		; Another 500 ms pause
	call	wait
	mov	A,=150		; 300 ms pause
	call	wait
	mov	r3,=$01		; select sound 01
	mov	r4,=0		; no pause
	mov	r6,=150		; 300ms 2400 Hz
	call	sound		; play tone
	mov	A,r7
	mov	r5,A
	jmp	main

trunk2n:mov	r3,=$00		; select sound 00
	mov	r4,=0		; no pause
	mov	A,r5
	mov	r7,A
	mov	r5,=%00000011	; select sample bank 03
	mov	r6,=65		; 130 ms 2400/2600 Hz
	call	sound		; play tone
	mov	A,=250		; 500 ms pause
	call	wait
	mov	A,=250		; Another 500 ms pause
	call	wait
	mov	A,=250		; Another 500 ms pause
	call	wait
	mov	A,=250		; Another 500 ms pause
	call	wait
	mov	r3,=$01		; select sound 01
	mov	r4,=0		; no pause
	mov	r6,=65		; 130ms 2400 Hz
	call	sound		; play tone
	mov	A,r7
	mov	r5,A
	jmp	main

ltrunkn:mov	A,=$50		; select sound 05
	outl	p2,a		; no pause
	mov	A,=%11111111	; set sample bank 03
	outl	p1,A
	call	releaseb
	call	silence
	jmp	main		; goto main loop

dhls2:	mov	A,r5
	mov	r7,A
	mov	r5,=1		; Samplebank 1
	mov	r3,=$0f		; Sample #15 DHLS Tone.
	mov	r6,=250		; Wait 0.5s
	call	sound
	mov	A,r7
	mov	r5,A
	jmp	main

red:	mov	r7,A
	mov	r3,=$0e		; select sound 14
	mov	A,r5
	mov	r1,A
	mov	r5,=%00000011	; select sample bank 03
	call	sound		; play tone
	mov	A,r1
	mov	r5,A
	mov	A,r7
	dec	A
	jnz	red
	jmp	main

; The End!