procedure press_button_page_1
    % user prompt and button having illusion of being pressed for first page
    % of model.
    loop
	getch (reply)
	if reply = "e" or reply = "E" then
	    drawfill (52, 68, 0, 0)
	    drawbox (56, 72, 70, 78, 5)
	    drawfill (57, 73, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (57, 70, 0, 0)
	    drawbox (51, 67, 75, 83, 13)
	    drawfill (54, 69, 13, 13)
	    delay (200)
	    pagenum := 3
	    flag := 1
	elsif reply = "m" or reply = "M" then
	    drawfill (52, 28, 0, 0)
	    drawbox (56, 32, 70, 38, 5)
	    drawfill (57, 33, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (54, 30, 0, 0)
	    drawbox (51, 28, 75, 42, 13)
	    drawfill (54, 29, 13, 13)
	    delay (200)
	    flag := 2
	else
	    sound (100, 100)
	    flag := 0
	end if
	exit when flag = 1 or flag = 2
    end loop
end press_button_page_1

procedure press_button_page_2
    % buttons having the illusion of being pressed for second page of model
    loop
	getch (reply)
	if reply = chr (209) then % if pgdn is entered
	    drawbox (51, 223, 75, 239, 0)
	    drawfill (52, 224, 0, 0)
	    drawbox (56, 228, 70, 234, 5)
	    drawfill (57, 229, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (57, 226, 0, 0)
	    drawbox (51, 223, 75, 239, 13)
	    drawfill (54, 225, 13, 13)
	    delay (200)
	    flag := 1
	    if pagenum = 4 then
		pagenum := 1
	    else
		pagenum := pagenum + 1
	    end if
	    cls
	    exit
	elsif reply = chr (201) then % if pgup is entered
	    drawfill (52, 266, 0, 0)
	    drawbox (56, 270, 70, 276, 5)
	    drawfill (57, 271, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (57, 268, 0, 0)
	    drawbox (51, 265, 75, 281, 13)
	    drawfill (54, 267, 13, 13)
	    delay (200)
	    if pagenum = 1 then
		pagenum := 4
	    else
		pagenum := pagenum - 1
	    end if
	    flag := 1
	    cls
	    exit
	elsif reply = "m" or reply = "M" then
	    drawbox (51, 183, 75, 199, 0)
	    drawfill (52, 184, 0, 0)
	    drawbox (56, 188, 70, 194, 5)
	    drawfill (57, 189, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (57, 186, 0, 0)
	    drawbox (51, 183, 75, 199, 13)
	    drawfill (54, 185, 13, 13)
	    delay (200)
	    flag := 2
	    exit
	else
	    sound (100, 100)
	    flag := 0
	end if
    end loop
end press_button_page_2

procedure blink1
    % blinking star on polonium oval
    delay (300)
    sound (9000, 100)
    delay (100)
    drawline (115, 223, 117, 227, 15)
    drawline (117, 223, 115, 227, 15)
    delay (200)
    drawline (115, 223, 117, 227, 7)
    drawline (117, 223, 115, 227, 7)
    locate (1, 1)
end blink1

procedure blink2
    % blinking star on gold foil
    sound (9000, 100)
    delay (100)
    drawline (508, 223, 510, 227, 15)
    drawline (510, 223, 508, 227, 15)
    delay (200)
    drawline (508, 223, 510, 227, 0)
    drawline (510, 223, 508, 227, 0)
    drawline (510, 200, 510, 250, 14)
end blink2

procedure blink3
    % blinking star on phosphor screen straight through
    delay (300)
    sound (9000, 100)
    delay (100)
    drawline (588, 223, 590, 227, 15)
    drawline (590, 223, 588, 227, 15)
    delay (200)
    drawline (588, 223, 590, 227, 0)
    drawline (590, 223, 588, 227, 0)
    drawarc (500, 225, 90, 70, 205, 153, 10)
end blink3

procedure blink4
    % blinking star on phosphor screen deflected
    sound (9000, 100)
    delay (100)
    drawline (558, 275, 560, 279, 15)
    drawline (560, 275, 558, 279, 15)
    delay (200)
    drawline (558, 275, 560, 279, 0)
    drawline (560, 275, 558, 279, 0)
    drawarc (500, 225, 90, 70, 205, 153, 10)
end blink4

procedure blink5
    % blinking star on phosphor screen reflected
    sound (9000, 100)
    delay (100)
    drawline (438, 275, 440, 279, 15)
    drawline (440, 275, 438, 279, 15)
    delay (200)
    drawline (438, 275, 440, 279, 0)
    drawline (440, 275, 438, 279, 0)
    drawarc (500, 225, 90, 70, 205, 153, 10)
end blink5


procedure leadbox
    % draw lead box
    drawline (70, 200, 70, 250, 7)
    drawline (70, 200, 130, 200, 7)
    drawline (70, 250, 130, 250, 7)
    drawline (130, 200, 130, 215, 7)
    drawline (130, 250, 130, 235, 7)
    drawline (130, 235, 100, 235, 7)
    drawline (130, 215, 100, 215, 7)
    drawline (100, 235, 100, 215, 7)
    drawfill (101, 236, 8, 7)
    drawoval (110, 225, 7, 7, 7)
    drawfill (110, 225, 7, 7)
end leadbox

procedure phosphorscreen
    % draw phosphor screen
    drawarc (500, 225, 90, 70, 205, 153, 10)
end phosphorscreen

procedure goldfoil
    % draw gold foil
    drawline (510, 200, 510, 250, 14)
    drawline (511, 200, 511, 250, 14)
end goldfoil

procedure sec_thir_part
    % alpha particle emitted from polonium source
    blink1
    delay (250)
    x := 120
    for i : 1 .. 19
	x := x + 20
	drawoval (x, 225, 1, 1, 14)
	delay (100)
	drawoval (x, 225, 1, 1, 0)
	delay (100)
    end for
    blink2
end sec_thir_part

% Procedure draws Rutherford's experiment on the screen.  It also acts as the
% first page of information in this model.
procedure experiment
    colorback (1)
    drawbox (0, 0, maxx, maxy, 2)
    color (14)
    locate (2, 9)
    put "R U T H E R F O R D ' S   G O L D   F O I L   E X P E R I M E N T"
    leadbox
    phosphorscreen
    goldfoil

    % draw pointers
    color (12)
    drawline (123, 225, 155, 225, 15)
    locate (9, 21)
    put "source of alpha particles"
    locate (10, 21)
    put "such as polonium"

    drawline (115, 188, 155, 188, 15)
    drawline (115, 188, 100, 198, 15)
    locate (12, 21)
    put "lead box"

    drawline (506, 225, 400, 225, 15)
    drawline (400, 225, 350, 182, 15)
    locate (13, 40)
    put "gold foil"

    drawline (435, 132, 470, 132, 15)
    drawline (470, 132, 500, 152, 15)
    locate (16, 40)
    put "phosphor screen"
    locate (17, 40)
    put "(flashes a light when alpha particles"
    locate (18, 40)
    put " hit it)"

    colour (14)
    locate (20, 13)
    put "Press 'Enter' to perform experiment!"
    locate (20, 20)
    color (12)
    put "Enter"

    colour (14)
    locate (23, 13)
    color (14)
    put "Press 'S' to skip experiment!"
    locate (23, 20)
    color (12)
    put "S"
    color (14)
    % draw Enter and Skip boxes
    drawbox (48, 64, 78, 86, 5)
    drawbox (51, 67, 75, 83, 13)
    drawfill (52, 68, 13, 13)

    drawbox (48, 24, 78, 46, 5)
    drawbox (51, 27, 75, 43, 13)
    drawfill (52, 28, 13, 13)
    locate (24, 44)
    color (2)
    put "-1-"
    loop
	  % checks to see what key is inputted by user
	getch (reply)
	if reply = "s" or reply = "S" then
	    drawfill (52, 28, 0, 0)
	    drawbox (56, 32, 70, 38, 5)
	    drawfill (57, 33, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (54, 30, 0, 0)
	    drawbox (51, 28, 75, 42, 13)
	    drawfill (54, 29, 13, 13)
	    flag := 1
	    pagenum := 2
	elsif reply = chr (10) then
	    drawfill (52, 68, 0, 0)
	    drawbox (56, 72, 70, 78, 5)
	    drawfill (57, 73, 5, 5)
	    sound (500,100)
	    delay (200)
	    drawfill (57, 70, 0, 0)
	    drawbox (51, 67, 75, 83, 13)
	    drawfill (54, 69, 13, 13)
	    flag := 2
	    pagenum := 2
	else
	    sound (100, 100)
	    flag := 0
	end if
	exit when flag not= 0
    end loop
    cls
    colorback (1)
    drawbox (0, 0, maxx, maxy, 2)
    color (14)
    locate (2, 9)
    put "R U T H E R F O R D ' S   G O L D   F O I L   E X P E R I M E N T"
    leadbox
    phosphorscreen
    goldfoil
    locate (24, 44)
    color (2)
    put "-1-"

    if flag = 2 then
	    % if user inputs key stating he/she wishes to see experiment ...

	color (13)
	locate (5, 10)
	put "Remember - this is in slow motion!"

	% first alpha particle
	blink1
	delay (250)
	x := 120

	% following counted loop gives illusion of alpha particle darting
	% across screen in experiment.
	for i : 1 .. 19
	    x := x + 20
	    drawoval (x, 225, 1, 1, 14)
	    if i = 7 then
		drawline (262, 220, 275, 200, 15)
		locate (11, 30)
		color (12)
		put "alpha particle"
		delay (800)
		drawline (262, 220, 275, 200, 0)
		locate (11, 30)
		color (0)
		put "alpha particle"
	    end if
	    delay (100)
	    drawoval (x, 225, 1, 1, 0)
	    delay (100)
	end for
	blink2

	% alpha particle goes straight through
	for i : 1 .. 3
	    x := x + 20
	    drawoval (x, 225, 1, 1, 14)
	    delay (100)
	    drawoval (x, 225, 1, 1, 0)
	    delay (100)
	end for
	blink3
	color (14)
	locate (9, 76)
	put "A"

	sec_thir_part

	% alpha particle is deflected
	y := 215
	x := 500
	for i : 1 .. 3
	    x := x + 18
	    y := y + 20
	    drawoval (x, y, 1, 1, 14)
	    delay (100)
	    drawoval (x, y, 1, 1, 0)
	    delay (100)
	end for
	blink4
	color (13)
	locate (5, 72)
	put "B"

	sec_thir_part

	% alpha particle reflected back
	y := 215
	x := 480
	for i : 1 .. 3
	    x := x - 15
	    y := y + 18
	    drawoval (x, y, 1, 1, 14)
	    delay (100)
	    drawoval (x, y, 1, 1, 0)
	    delay (100)
	end for
	blink5
	color (12)
	locate (5, 55)
	put "C"

    end if
    color (14)
    locate (9, 76)
    put "A"
    color (13)
    locate (5, 72)
    put "B"
    color (12)
    locate (5, 55)
    put "C"
    color (14)
    locate (20, 13)
    put "Press ' ' for explanation"
    locate (20, 20)
    color (12)
    put "E"

    color (14)
    locate (23, 13)
    put "Main Menu (M)"

    drawbox (48, 64, 78, 86, 5)
    drawbox (51, 67, 75, 83, 13)
    drawfill (52, 68, 13, 13)

    drawbox (48, 24, 78, 46, 5)
    drawbox (51, 27, 75, 43, 13)
    drawfill (52, 28, 13, 13)
    press_button_page_1
end experiment

% Procedure contains information for the first page of explanation for the
% experiment and Rutherford's model.
procedure explain_page1
    colorback (1)
    drawbox (0, 0, maxx, maxy, 2)
    color (14)
    locate (2, 9)
    put "R U T H E R F O R D ' S   G O L D   F O I L   E X P E R I M E N T"

    phosphorscreen
    goldfoil
    color (14)
    locate (9, 76)
    put "A"
    color (13)
    locate (5, 72)
    put "B"
    color (12)
    locate (5, 55)
    put "C"
    color (14)
    locate (15, 2)
    put "A - "
    color (3)
    locate (15, 6)
    put
	"Rutherford thought  that if the  positive particles  were clustered  in a"
    locate (16, 6)
    put
	"small centre of the atom, then most of the alpha particles would not come"
    locate (17, 6)
    put
	"close enough to the  centre to be deflected.  Thus, most particles passed"
    locate (18, 6)
    put "straight through the gold foil."

    color (13)
    locate (19, 2)
    put "B -"
    color (3)
    locate (19, 6)
    put
	"Some particles that  came close  to the  centre were  slightly deflected."
    color (12)
    locate (20, 2)
    put "C -"
    color (3)
    locate (20, 6)
    put
	"Every once  in a while, an  alpha particle would  collide almost directly"
    locate (21, 6)
    put
	"with the centre and its course would be changed dramatically.  This would"
    locate (22, 6)
    put
	"occur about once for every ten thousand alpha particles emitted."
    color (14)
    locate (6, 12)
    put "PgUp (back to experiment)"
    drawbox (48, 262, 78, 284, 5)
    drawbox (51, 265, 75, 281, 13)
    drawfill (52, 266, 13, 13)
    locate (9, 12)
    put "PgDn"
    drawbox (48, 220, 78, 242, 5)
    drawbox (51, 223, 75, 239, 13)
    drawfill (52, 224, 13, 13)
    locate (12, 12)
    put "Main Menu (M)"
    drawbox (48, 180, 78, 202, 5)
    drawbox (51, 183, 75, 199, 13)
    drawfill (52, 184, 13, 13)
    locate (24, 39)
    color (2)
    put "-2-"
    locate (1, 1)
    press_button_page_2
end explain_page1


% Procedure contains information for the second page of explanation for the
% experiment and Rutherford's model.
procedure explain_page2
    colorback (1)
    drawbox (0, 0, maxx, maxy, 2)
    color (14)
    locate (2, 9)
    put "R U T H E R F O R D ' S   G O L D   F O I L   E X P E R I M E N T"
    drawbox (4, 4, maxx - 4, 300, 2)
    color (3)
    locate (5, 3)
    put
	"Rutherford's experiment could not be explained by Thomson's model. According"
    locate (6, 3)
    put
	"to  Thomson,  the  atom  is composed  of a  sphere of  uniformly distributed"
    locate (7, 3)
    put
	"positive electricity. Therefore, Rutherford thought that all alpha particles"
    locate (8, 3)
    put
	"would be repelled evenly by this evenly distributed positive electricity."

    % first set of alpha particles and gold atoms
    color (12)
    locate (10, 5)
    put "ALPHA PARTICLES"
    drawoval (80, 193, 3, 3, 12)
    drawoval (80, 183, 3, 3, 12)
    drawoval (80, 173, 3, 3, 12)
    drawoval (80, 163, 3, 3, 12)
    locate (10, 35)
    put "GOLD ATOMS"
    drawoval (304, 195, 5, 4, 14)
    drawoval (316, 195, 5, 4, 14)
    drawoval (310, 187, 5, 4, 14)
    drawoval (304, 179, 5, 4, 14)
    drawoval (316, 179, 5, 4, 14)
    drawoval (310, 171, 5, 4, 14)
    drawoval (304, 163, 5, 4, 14)
    drawoval (316, 163, 5, 4, 14)

    % arrows
    drawline (90, 193, 311, 193, 15)
    drawarc (312, 198, 25, 5, 270, 4, 15)
    drawline (337, 198, 330, 198, 15)
    drawline (337, 198, 334, 192, 15)

    drawline (90, 183, 313, 183, 15)
    drawarc (312, 188, 25, 5, 270, 4, 15)
    drawline (337, 188, 330, 188, 15)
    drawline (337, 188, 334, 182, 15)

    drawline (90, 173, 325, 173, 15)
    drawarc (310, 169, 25, 5, 3, 50, 15)
    drawline (335, 170, 334, 175, 15)
    drawline (335, 169, 328, 169, 15)

    drawline (90, 163, 325, 163, 15)
    drawarc (310, 159, 25, 5, 3, 50, 15)
    drawline (335, 160, 334, 165, 15)
    drawline (335, 159, 328, 159, 15)

    color (3)
    locate (11, 45)
    put "*For Thomson's model to be correct,"
    locate (12, 45)
    put " this is what should have happened"
    locate (13, 45)
    put " in Rutherford's experiment:"
    locate (14, 47)
    put "-all alpha particles should have"
    locate (15, 47)
    put " passed through gold foil evenly."

    % next set of alpha particles
    drawoval (80, 123, 3, 3, 12)
    drawoval (80, 113, 3, 3, 12)
    drawoval (80, 100, 3, 3, 12)
    drawoval (80, 91, 3, 3, 12)
    % next set of gold atoms
    drawoval (304, 125, 5, 4, 14)
    drawoval (316, 125, 5, 4, 14)
    drawoval (310, 117, 5, 4, 14)
    drawoval (304, 109, 5, 4, 14)
    drawoval (316, 109, 5, 4, 14)
    drawoval (310, 101, 5, 4, 14)
    drawoval (304, 93, 5, 4, 14)
    drawoval (316, 93, 5, 4, 14)
    % nuclei of gold atoms
    drawoval (304, 125, 1, 1, 14)
    drawoval (316, 125, 1, 1, 14)
    drawoval (310, 117, 1, 1, 14)
    drawoval (304, 109, 1, 1, 14)
    drawoval (316, 109, 1, 1, 14)
    drawoval (310, 101, 1, 1, 14)
    drawoval (304, 93, 1, 1, 14)
    drawoval (316, 93, 1, 1, 14)
    % next set of arrows
    drawline (90, 122, 331, 122, 15)
    drawline (331, 122, 326, 125, 15)
    drawline (331, 122, 326, 119, 15)
    drawline (90, 113, 331, 113, 15)
    drawline (331, 113, 326, 116, 15)
    drawline (331, 113, 326, 110, 15)
    drawline (90, 99, 313, 99, 15)
    drawline (313, 99, 330, 95, 15)
    drawline (330, 95, 328, 99, 15)
    drawline (331, 95, 325, 92, 15)
    drawline (90, 93, 303, 93, 15)
    drawline (303, 93, 280, 87, 15)
    drawline (280, 87, 283, 91, 15)
    drawline (280, 87, 286, 85, 15)

    color (3)
    locate (17, 45)
    put "* This is what actually happened in"
    locate (18, 45)
    put "  Rutherford's experiment:"
    locate (19, 47)
    put "-most particles passed through"
    locate (20, 47)
    put " the gold foil."
    locate (21, 47)
    put "-a few particles were deflected"
    locate (22, 47)
    put " by the gold foil."
    locate (23, 47)
    put "-a rare particle bounced back"
    locate (24, 47)
    put " after hitting the gold foil!"
    locate (24, 39)
    color (2)
    put "-3-"
    % page up button
    color (14)
    drawbox (38, 39, 68, 61, 5)
    drawbox (41, 42, 65, 58, 13)
    drawfill (42, 43, 13, 13)
    locate (24, 6)
    put "PgUp"

    % page down button
    drawbox (95, 39, 125, 61, 5)
    drawbox (98, 42, 122, 58, 13)
    drawfill (100, 43, 13, 13)
    locate (24, 13)
    put "PgDn"

    % menu button
    drawbox (152, 39, 182, 61, 5)
    drawbox (155, 42, 179, 58, 13)
    drawfill (157, 43, 13, 13)
    locate (24, 19)
    put "Main Menu (Q)"
    across_keys
end explain_page2

% Procedure contains information for the third page of explanation for the
% experiment and Rutherford's model.
procedure explain_page3
    colorback (1)
    drawbox (0, 0, maxx, maxy, 2)
    color (14)
    locate (2, 11)
    put "R U T H E R F O R D ' S   M O D E L   O F   T H E   A T O M"


    % draw the atom
    drawoval (99, 231, 55, 42, 12)
    drawoval (99, 231, 10, 9, 4)
    color (4)
    locate (9, 13)
    put "+"

    % draw pointers
    drawline (155, 287, 130, 273, 15)
    drawline (155, 287, 195, 287, 15)
    color (12)
    locate (4, 26)
    put "An atom is  composed of a  positive area of high mass"
    locate (5, 26)
    put "in the centre called the nucleus. Around the nucleus,"
    locate (6, 26)
    put "electrons revolve like bees around a hive. Therefore, "
    locate (7, 26)
    put "most of the atom is empty space."

    drawbox (200, 20, 620, 243, 2)
    draw_keys
    if ch = chr (209) or ch = chr (201) then
	drawpage
    end if
    color (2)
    locate (9, 43)
    put "RUTHERFORD'S MODEL"
    color (12)
    locate (11, 28)
    put "Main postulate:"
    color (3)
    locate (11, 44)
    put "an  atom  is mostly  empty space"
    locate (12, 44)
    put "with all of  the positive charge"
    locate (13, 44)
    put "and most of the  mass located in"
    locate (14, 44)
    put "a central part called a nucleus."
    locate (16, 28)
    put " Based on his gold  foil experiment, Rutherford"
    locate (17, 28)
    put "   was able to develop this model of the atom."
    locate (24, 10)
    color (14)
    put "(to experiment)"
    locate (23, 51)
    color (2)
    put "-4-"
    loop
	exit when hasch
	color (15)
	locate (7, 13)
	put "-"
	locate (9, 17)
	put "-"
	locate (11, 13)
	put "-"
	locate (9, 9)
	put "-"
	delay (150)
	exit when hasch
	color (0)
	locate (7, 13)
	put "-"
	locate (9, 17)
	put "-"
	locate (11, 13)
	put "-"
	locate (9, 9)
	put "-"
	delay (150)
	exit when hasch
	color (15)
	locate (8, 17)
	put "-"
	locate (10, 16)
	put "-"
	locate (10, 10)
	put "-"
	locate (8, 10)
	put "-"
	delay (150)
	exit when hasch
	color (0)
	locate (8, 17)
	put "-"
	locate (10, 16)
	put "-"
	locate (10, 10)
	put "-"
	locate (8, 10)
	put "-"
	delay (150)
	exit when hasch
    end loop
    pgup_pgdn
end explain_page3

% Is the main call up procedure for this model.  It calls up all procedures
% necessary for this option to work properly.
procedure ruther_main
    flag := 0
    pagenum := 1
    loop
	    % following statements check to see which procedure needs to
	    % be called up next.
	exit when flag = 2
	if pagenum = 1 or pagenum = 2 then
	    experiment
	    if flag = 1 then
		cls
	    end if
	elsif pagenum = 3 then
	    delay (200)
	    explain_page1
	    if flag = 1 then
		cls
	    end if
	    delay (200)
	elsif pagenum = 4 then
	    delay (200)
	    explain_page2
	    flush
	    if flag = 1 then
		cls
	    end if
	    delay (200)
	elsif pagenum = 5 then
	    delay (200)
	    explain_page3
	    if flag = 1 then
		cls
	    end if
	    delay (200)
	end if
    end loop
end ruther_main
