Old lady swallowed a fly: Difference between revisions

Commodore BASIC: Decided to add a dedicated "non-music" version.
(Added Commodore BASIC (64. Plus/4, 128 with sound))
(Commodore BASIC: Decided to add a dedicated "non-music" version.)
Line 621:
 
=={{header|Commodore BASIC}}==
The portion of the program that handles the lyric logic (the "No Sound" version) is universal and should work across all Commodore models. Since a sound chip is available in Commodore BASIC on the C64, Plus/4, and 128, it is not difficult to take advantage of this. The 64 and Plus/4 versions demonstrate a very rudimentary music player based on the syntax used for the C128Commodore 128's PLAY command (thus making the data statements nearly identical in allthose three versions.)
 
The music is not quite as procedural as the lyric strings, since the music is tailored to the unique number of syllables for each phrase, however, each verse does utilize three basic music phrases that can be iterated through.
To use the program without music, omit the music data statements lines 1100 through 1180, the music playing routines lines 2000 through 2599, and remove all GOSUB references to lines 2000 and 2500.
 
===Commodore BASIC (No Sound)===
The music is not quite as procedural as the lyric strings, since the music is tailored to the unique number of syllables for each phrase, however, each verse does utilize three basic phrases that can be iterated through.
<lang gwbasic>
1 rem rosetta code
2 rem old lady who swallowed a fly
5 print chr$(147);chr$(14)
10 dim a$(10),ex$(10),mu$(8,3):a=1
15 for i=1 to 8:read a$(i),ex$(i):next i
20 for c=1 to 8
30 print chr$(147):print " Old Lady Who Swallowed A Fly ":print
40 print "I know an old lady who swallowed"
45 print " a ";a$(c):gosub 200
50 for bc=c to 1 step -1
55 if bc=c or bc<=2 then print ex$(bc):gosub 200
57 if bc=8 then for t=1 to 1500:next
60 if bc>1 then print "She swallowed a "a$(bc)" to catch the "a$(bc-1)";"
61 gosub 200
65 next bc
70 print " ... Perhaps she'll die!"
75 get k$:if k$="q" then end
77 if k$>"0" and k$<"9" then c=asc(k$)-49
80 print:for t=1 to 1000:next t
90 next c
100 end
 
200 for t=1 to 500:next t:return:rem generic delay
 
1000 rem lyrics
1010 data "fly","I don't know why she swallowed a fly..."
1020 data "spider","That wriggled and jiggled and tickled inside her!"
1030 data "bird","How absurd to swallow a bird!"
1040 data "cat","Imagine that! She swallowed a cat!"
1050 data "dog","What a hog, to swallow a dog!"
1060 data "goat","She just opened her throat and swallowed a goat!"
1070 data "cow","I don't know how she swallowed a cow!"
1080 data "horse","...She died, of course!"
</lang>
 
===Commodore 64===
Line 769 ⟶ 804:
2599 return
</lang>
 
 
===Commodore 128===
113

edits