
'Program Electronic Brain
main:
		pause 500
		high 0
		if pin2=1 then label_114
label_D:   INPUT 4
label_14: let b6= 0
label_1B: let b2= 10
label_22: let b1= 200
		if b6= 1 then label_23E
		let b6=b6- 5
label_29: if pin4=1 then label_34
		pause 50
		let b1=b1- 1
		if b1= 0 then label_B9
		goto label_29

label_34: pause 200
		let b2=b2- 1
		if b2= 0 then label_77
		if pin4=1 then label_34
		let b0=b0+ 1
		goto label_1B

label_77: gosub sub0
		goto label_D

label_B9: if b0= 0 then label_22
		gosub sub1
		goto label_22

label_114: high 4
		 low 1
		 if pin3=1 then label_D
		 low 2
		 goto label_114

label_23E: low 0
		 goto label_29

sub0:	low 0
	 	if pin3=1 then label_21F
	 	gosub sub3
label_279: high 0
		 return

label_21F: if b0> 4 then label_139
		  let b5= 0
label_14A: let b4= 110
label_151: INC b4
	 	sound  2,(b4,1)
	 	if b4> 127 then label_20A
	 	goto label_151

label_139: gosub sub2
label_176: high 4
		 high 1
label_184: pause 250
		 let b0=b0- 1
		 if b0= 0 then label_19E
	 	goto label_184

label_19E: low 1
		 goto label_279

label_20A: INC b5
		 if b5> 10 then label_176
		 goto label_14A

sub1:	low 0
		 OUTPUT 4
	 	let b3=b0
label_122: pause 600
	 	if b3> 4 then label_E5
	 	if b3= 0 then label_C5
	 	let b3=b3- 1
	 	high 4
	 	pause 100
	 	low 4
	 	goto label_122

label_C5: INPUT 4
		high 0
		return

label_E5: let b3=b3- 4
		high 0
		pause 300
		low 0
		goto label_122
 
sub2:	tune 3, 3,($27,$00,$2C,$00,$02,$6C,$02,$44,$47,$04,$00,$2C,$C9,$02,$05,$C4,$00,$2C)
		 return

sub3:	if b0> 3 then label_1C3

		select case b0
		case 0
		    play 0,3
		case 1
		    play 1,3 
		case 2
		    play 2,3 
		case 3
		    play 3,3
		end select
label_1F0: return

label_1C3: if b0> 4 then label_1CE
label_1DE: let b0=b0- 1

		select case b0
		case 0
		    play 0,3
		case 1
		    play 1,3 
		case 2
		    play 2,3 
		case 3
		    play 3,3
		end select
		  if b0= 0 then label_1F0
		  goto label_1DE

label_1CE: gosub sub2
		  goto label_1F0


