Home » Personal collection » Acorn DFS disks » dfs_box03_disk12_bcpl.scp » EXMP2B

EXMP2B

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn DFS disks » dfs_box03_disk12_bcpl.scp
Filename: EXMP2B
Read OK:
File size: 1143 bytes
Load address: 0000
Exec address: 0000
File contents
section "EXMP2"


get "exmphdr"


// This section of EXAMPLE contains the procedure to play a tune.



// PLAYTUNE uses the ENVELOPE and SOUND procedures to play a simple tune. The

// tune is stored in a string. Each note is represented by 3 characters - the

// octave number, the note (a-g) and +, - or space for sharp, flat or

// natural. The note is in lower case for a quaver and upper case for a

// crotchet. The first note in a bar is preceded by '!'. The string is assumed

// to be valid.


let playtune() be

$( let envnumber = 1          // envelope to use

   let pitch = ?              // pitch parameter for SOUND

   let sbuffsz = adval(-6)    // size of sound buffer 1 (number of free slots)

   let soundvec = vec 3       // parameter for SOUND

   let tune = "!3b-*

              *!4e-4e-4e-4e-4e-4e-*

              *!4d 4f 4b-4b-4a-4f *

              *!4e-4e-4e-4e-4d 4e-*

              *!4f 3b-3b-3B-3b-*

              *!4e-4e-4e-4e-4e-4e-*

              *!4d 4f 4b-4b-4a-4f *

              *!4g 4b-4e-4f 4e-4f *

              *!4e-3e-3e-3E-"


   // NOTEVAL is a table of the pitch for the notes in one octave,

   // starting with A and taking C as 0.


   let noteval = table 36, 44, 0, 8, 16, 20, 28


   // Set up screen display then set up envelopes. Envelope 1

   // is for quaver. Envelope 2 is for crotchet. Envelope 3

   // is for accented quaver at start of bar. (There are no

   // accented crotchets.)


   dodisplay()

   envelope(table 1, 2, 0, 0, 0, 0, 0, 0, 30,  -2, -127, -127, 120, 105)

   envelope(table 2, 2, 0, 0, 0, 0, 0, 0, 60,  -6,  -30, -127, 120,  60)

   envelope(table 3, 2, 0, 0, 0, 0, 0, 0, 64, -10,  -65, -127, 126,  59)


   soundvec!0 := 1         // initialise channel number


   // Process each character in the tune string.


   for i = 1 to tune%0 do

   $( let ch = tune%i


      test '1' <= ch <= '7' then


      // Octave number - initialise pitch.

         pitch := 48*(ch-'0') - 91


      else test 'a' <= ch <= 'g' then


      // Note (quaver) - update pitch and leave envelope as 1 (or 3).

         pitch := pitch + noteval!(ch-'a')


      else test 'A' <= ch <= 'G' then


      // Note (crotchet) - update pitch and select envelope 2.

      $( pitch := pitch + noteval!(ch-'A')

         envnumber := 2

      $)


      else test ch = '!' then


      // Start of bar so set envelope 3 for following note.

         envnumber := 3


      else


      // Assume '+', '-' or space so adjust pitch for sharp or

      // flat if appropriate then play the note.

      $( test ch = '+' then

            pitch := pitch + 4

         else if ch = '-' then

            pitch := pitch - 4


         soundvec!1 := envnumber

         soundvec!2 := pitch

         soundvec!3 := envnumber = 2 -> 6, 3 // duration (longer for crotchet)

         sound(soundvec)


         envnumber := 1    // reset envelope number to quaver.

      $)

   $)                      // back for next character


   // All notes put in buffer. Wait until they have been played

   // before returning to the menu.


   until adval(-6) = sbuffsz loop      // wait for tune to end

$)



// DISPNOTE displays a note symbol in flashing white at a specified x position.


and dispnote(x) be

$( let chartab = table 160,160,234,228,   // 4x5 array of graphics chars

                       141,160,234,160,   // double height

                       141,160,234,160,

                       160,248,254,160,

                       160,181,234,160,

                       160,171,167,160

   for i=0 to 5 do

   $( txtcursor(x, 3+i)    // position character on line 3

      wrbin(136)           // flashing

      wrbin(151)           // graphic white

      for j=4*i to 4*i+3 do

         wrbin(chartab!j)

      wrbin(137)           // steady

   $)

$)



// DODISPLAY sets up the display.


and dodisplay() be

$( mode(7)

   for i = 0 to 1 do       // double height title

   $( txtcursor(10, i+4)

      writes("*x8D*x81*x9D*x86M U S I C  *x9C")

   $)

   dispnote(1); dispnote(29)        // note symbols

   txtcursor(1, 10)

   for i = 0 to 14 do

   $( wrbin(129 + (i rem 3))        // select one of three colours

      writes("MUSIC")

      wrbin(10)                     // cursor down then 4 left

      for j = 1 to 4 do wrbin(8)

   $)

   txtcursor(0, 23)        // leave cursor at end of screen

$)

.


00000000  73 65 63 74 69 6f 6e 20  22 45 58 4d 50 32 22 0a  |section "EXMP2".|
00000010  0d 0a 0d 67 65 74 20 22  65 78 6d 70 68 64 72 22  |...get "exmphdr"|
00000020  0a 0d 0a 0d 2f 2f 20 54  68 69 73 20 73 65 63 74  |....// This sect|
00000030  69 6f 6e 20 6f 66 20 45  58 41 4d 50 4c 45 20 63  |ion of EXAMPLE c|
00000040  6f 6e 74 61 69 6e 73 20  74 68 65 20 70 72 6f 63  |ontains the proc|
00000050  65 64 75 72 65 20 74 6f  20 70 6c 61 79 20 61 20  |edure to play a |
00000060  74 75 6e 65 2e 0a 0d 0a  0d 0a 0d 2f 2f 20 50 4c  |tune.......// PL|
00000070  41 59 54 55 4e 45 20 75  73 65 73 20 74 68 65 20  |AYTUNE uses the |
00000080  45 4e 56 45 4c 4f 50 45  20 61 6e 64 20 53 4f 55  |ENVELOPE and SOU|
00000090  4e 44 20 70 72 6f 63 65  64 75 72 65 73 20 74 6f  |ND procedures to|
000000a0  20 70 6c 61 79 20 61 20  73 69 6d 70 6c 65 20 74  | play a simple t|
000000b0  75 6e 65 2e 20 54 68 65  0a 0d 2f 2f 20 74 75 6e  |une. The..// tun|
000000c0  65 20 69 73 20 73 74 6f  72 65 64 20 69 6e 20 61  |e is stored in a|
000000d0  20 73 74 72 69 6e 67 2e  20 45 61 63 68 20 6e 6f  | string. Each no|
000000e0  74 65 20 69 73 20 72 65  70 72 65 73 65 6e 74 65  |te is represente|
000000f0  64 20 62 79 20 33 20 63  68 61 72 61 63 74 65 72  |d by 3 character|
00000100  73 20 2d 20 74 68 65 0a  0d 2f 2f 20 6f 63 74 61  |s - the..// octa|
00000110  76 65 20 6e 75 6d 62 65  72 2c 20 74 68 65 20 6e  |ve number, the n|
00000120  6f 74 65 20 28 61 2d 67  29 20 61 6e 64 20 2b 2c  |ote (a-g) and +,|
00000130  20 2d 20 6f 72 20 73 70  61 63 65 20 66 6f 72 20  | - or space for |
00000140  73 68 61 72 70 2c 20 66  6c 61 74 20 6f 72 0a 0d  |sharp, flat or..|
00000150  2f 2f 20 6e 61 74 75 72  61 6c 2e 20 54 68 65 20  |// natural. The |
00000160  6e 6f 74 65 20 69 73 20  69 6e 20 6c 6f 77 65 72  |note is in lower|
00000170  20 63 61 73 65 20 66 6f  72 20 61 20 71 75 61 76  | case for a quav|
00000180  65 72 20 61 6e 64 20 75  70 70 65 72 20 63 61 73  |er and upper cas|
00000190  65 20 66 6f 72 20 61 0a  0d 2f 2f 20 63 72 6f 74  |e for a..// crot|
000001a0  63 68 65 74 2e 20 54 68  65 20 66 69 72 73 74 20  |chet. The first |
000001b0  6e 6f 74 65 20 69 6e 20  61 20 62 61 72 20 69 73  |note in a bar is|
000001c0  20 70 72 65 63 65 64 65  64 20 62 79 20 27 21 27  | preceded by '!'|
000001d0  2e 20 54 68 65 20 73 74  72 69 6e 67 20 69 73 20  |. The string is |
000001e0  61 73 73 75 6d 65 64 0a  0d 2f 2f 20 74 6f 20 62  |assumed..// to b|
000001f0  65 20 76 61 6c 69 64 2e  0a 0d 0a 0d 6c 65 74 20  |e valid.....let |
00000200  70 6c 61 79 74 75 6e 65  28 29 20 62 65 0a 0d 24  |playtune() be..$|
00000210  28 20 6c 65 74 20 65 6e  76 6e 75 6d 62 65 72 20  |( let envnumber |
00000220  3d 20 31 20 20 20 20 20  20 20 20 20 20 2f 2f 20  |= 1          // |
00000230  65 6e 76 65 6c 6f 70 65  20 74 6f 20 75 73 65 0a  |envelope to use.|
00000240  0d 20 20 20 6c 65 74 20  70 69 74 63 68 20 3d 20  |.   let pitch = |
00000250  3f 20 20 20 20 20 20 20  20 20 20 20 20 20 20 2f  |?              /|
00000260  2f 20 70 69 74 63 68 20  70 61 72 61 6d 65 74 65  |/ pitch paramete|
00000270  72 20 66 6f 72 20 53 4f  55 4e 44 0a 0d 20 20 20  |r for SOUND..   |
00000280  6c 65 74 20 73 62 75 66  66 73 7a 20 3d 20 61 64  |let sbuffsz = ad|
00000290  76 61 6c 28 2d 36 29 20  20 20 20 2f 2f 20 73 69  |val(-6)    // si|
000002a0  7a 65 20 6f 66 20 73 6f  75 6e 64 20 62 75 66 66  |ze of sound buff|
000002b0  65 72 20 31 20 28 6e 75  6d 62 65 72 20 6f 66 20  |er 1 (number of |
000002c0  66 72 65 65 20 73 6c 6f  74 73 29 0a 0d 20 20 20  |free slots)..   |
000002d0  6c 65 74 20 73 6f 75 6e  64 76 65 63 20 3d 20 76  |let soundvec = v|
000002e0  65 63 20 33 20 20 20 20  20 20 20 2f 2f 20 70 61  |ec 3       // pa|
000002f0  72 61 6d 65 74 65 72 20  66 6f 72 20 53 4f 55 4e  |rameter for SOUN|
00000300  44 0a 0d 20 20 20 6c 65  74 20 74 75 6e 65 20 3d  |D..   let tune =|
00000310  20 22 21 33 62 2d 2a 0a  0d 20 20 20 20 20 20 20  | "!3b-*..       |
00000320  20 20 20 20 20 20 20 2a  21 34 65 2d 34 65 2d 34  |       *!4e-4e-4|
00000330  65 2d 34 65 2d 34 65 2d  34 65 2d 2a 0a 0d 20 20  |e-4e-4e-4e-*..  |
00000340  20 20 20 20 20 20 20 20  20 20 20 20 2a 21 34 64  |            *!4d|
00000350  20 34 66 20 34 62 2d 34  62 2d 34 61 2d 34 66 20  | 4f 4b-4b-4a-4f |
00000360  2a 0a 0d 20 20 20 20 20  20 20 20 20 20 20 20 20  |*..             |
00000370  20 2a 21 34 65 2d 34 65  2d 34 65 2d 34 65 2d 34  | *!4e-4e-4e-4e-4|
00000380  64 20 34 65 2d 2a 0a 0d  20 20 20 20 20 20 20 20  |d 4e-*..        |
00000390  20 20 20 20 20 20 2a 21  34 66 20 33 62 2d 33 62  |      *!4f 3b-3b|
000003a0  2d 33 42 2d 33 62 2d 2a  0a 0d 20 20 20 20 20 20  |-3B-3b-*..      |
000003b0  20 20 20 20 20 20 20 20  2a 21 34 65 2d 34 65 2d  |        *!4e-4e-|
000003c0  34 65 2d 34 65 2d 34 65  2d 34 65 2d 2a 0a 0d 20  |4e-4e-4e-4e-*.. |
000003d0  20 20 20 20 20 20 20 20  20 20 20 20 20 2a 21 34  |             *!4|
000003e0  64 20 34 66 20 34 62 2d  34 62 2d 34 61 2d 34 66  |d 4f 4b-4b-4a-4f|
000003f0  20 2a 0a 0d 20 20 20 20  20 20 20 20 20 20 20 20  | *..            |
00000400  20 20 2a 21 34 67 20 34  62 2d 34 65 2d 34 66 20  |  *!4g 4b-4e-4f |
00000410  34 65 2d 34 66 20 2a 0a  0d 20 20 20 20 20 20 20  |4e-4f *..       |
00000420  20 20 20 20 20 20 20 2a  21 34 65 2d 33 65 2d 33  |       *!4e-3e-3|
00000430  65 2d 33 45 2d 22 0a 0d  0a 0d 20 20 20 2f 2f 20  |e-3E-"....   // |
00000440  4e 4f 54 45 56 41 4c 20  69 73 20 61 20 74 61 62  |NOTEVAL is a tab|
00000450  6c 65 20 6f 66 20 74 68  65 20 70 69 74 63 68 20  |le of the pitch |
00000460  66 6f 72 20 74 68 65 20  6e 6f 74 65 73 20 69 6e  |for the notes in|
00000470  20 6f 6e 65 20 6f 63 74  61 76 65 2c 0a 0d 20 20  | one octave,..  |
00000480  20 2f 2f 20 73 74 61 72  74 69 6e 67 20 77 69 74  | // starting wit|
00000490  68 20 41 20 61 6e 64 20  74 61 6b 69 6e 67 20 43  |h A and taking C|
000004a0  20 61 73 20 30 2e 0a 0d  0a 0d 20 20 20 6c 65 74  | as 0.....   let|
000004b0  20 6e 6f 74 65 76 61 6c  20 3d 20 74 61 62 6c 65  | noteval = table|
000004c0  20 33 36 2c 20 34 34 2c  20 30 2c 20 38 2c 20 31  | 36, 44, 0, 8, 1|
000004d0  36 2c 20 32 30 2c 20 32  38 0a 0d 0a 0d 20 20 20  |6, 20, 28....   |
000004e0  2f 2f 20 53 65 74 20 75  70 20 73 63 72 65 65 6e  |// Set up screen|
000004f0  20 64 69 73 70 6c 61 79  20 74 68 65 6e 20 73 65  | display then se|
00000500  74 20 75 70 20 65 6e 76  65 6c 6f 70 65 73 2e 20  |t up envelopes. |
00000510  45 6e 76 65 6c 6f 70 65  20 31 0a 0d 20 20 20 2f  |Envelope 1..   /|
00000520  2f 20 69 73 20 66 6f 72  20 71 75 61 76 65 72 2e  |/ is for quaver.|
00000530  20 45 6e 76 65 6c 6f 70  65 20 32 20 69 73 20 66  | Envelope 2 is f|
00000540  6f 72 20 63 72 6f 74 63  68 65 74 2e 20 45 6e 76  |or crotchet. Env|
00000550  65 6c 6f 70 65 20 33 0a  0d 20 20 20 2f 2f 20 69  |elope 3..   // i|
00000560  73 20 66 6f 72 20 61 63  63 65 6e 74 65 64 20 71  |s for accented q|
00000570  75 61 76 65 72 20 61 74  20 73 74 61 72 74 20 6f  |uaver at start o|
00000580  66 20 62 61 72 2e 20 28  54 68 65 72 65 20 61 72  |f bar. (There ar|
00000590  65 20 6e 6f 0a 0d 20 20  20 2f 2f 20 61 63 63 65  |e no..   // acce|
000005a0  6e 74 65 64 20 63 72 6f  74 63 68 65 74 73 2e 29  |nted crotchets.)|
000005b0  0a 0d 0a 0d 20 20 20 64  6f 64 69 73 70 6c 61 79  |....   dodisplay|
000005c0  28 29 0a 0d 20 20 20 65  6e 76 65 6c 6f 70 65 28  |()..   envelope(|
000005d0  74 61 62 6c 65 20 31 2c  20 32 2c 20 30 2c 20 30  |table 1, 2, 0, 0|
000005e0  2c 20 30 2c 20 30 2c 20  30 2c 20 30 2c 20 33 30  |, 0, 0, 0, 0, 30|
000005f0  2c 20 20 2d 32 2c 20 2d  31 32 37 2c 20 2d 31 32  |,  -2, -127, -12|
00000600  37 2c 20 31 32 30 2c 20  31 30 35 29 0a 0d 20 20  |7, 120, 105)..  |
00000610  20 65 6e 76 65 6c 6f 70  65 28 74 61 62 6c 65 20  | envelope(table |
00000620  32 2c 20 32 2c 20 30 2c  20 30 2c 20 30 2c 20 30  |2, 2, 0, 0, 0, 0|
00000630  2c 20 30 2c 20 30 2c 20  36 30 2c 20 20 2d 36 2c  |, 0, 0, 60,  -6,|
00000640  20 20 2d 33 30 2c 20 2d  31 32 37 2c 20 31 32 30  |  -30, -127, 120|
00000650  2c 20 20 36 30 29 0a 0d  20 20 20 65 6e 76 65 6c  |,  60)..   envel|
00000660  6f 70 65 28 74 61 62 6c  65 20 33 2c 20 32 2c 20  |ope(table 3, 2, |
00000670  30 2c 20 30 2c 20 30 2c  20 30 2c 20 30 2c 20 30  |0, 0, 0, 0, 0, 0|
00000680  2c 20 36 34 2c 20 2d 31  30 2c 20 20 2d 36 35 2c  |, 64, -10,  -65,|
00000690  20 2d 31 32 37 2c 20 31  32 36 2c 20 20 35 39 29  | -127, 126,  59)|
000006a0  0a 0d 0a 0d 20 20 20 73  6f 75 6e 64 76 65 63 21  |....   soundvec!|
000006b0  30 20 3a 3d 20 31 20 20  20 20 20 20 20 20 20 2f  |0 := 1         /|
000006c0  2f 20 69 6e 69 74 69 61  6c 69 73 65 20 63 68 61  |/ initialise cha|
000006d0  6e 6e 65 6c 20 6e 75 6d  62 65 72 0a 0d 0a 0d 20  |nnel number.... |
000006e0  20 20 2f 2f 20 50 72 6f  63 65 73 73 20 65 61 63  |  // Process eac|
000006f0  68 20 63 68 61 72 61 63  74 65 72 20 69 6e 20 74  |h character in t|
00000700  68 65 20 74 75 6e 65 20  73 74 72 69 6e 67 2e 0a  |he tune string..|
00000710  0d 0a 0d 20 20 20 66 6f  72 20 69 20 3d 20 31 20  |...   for i = 1 |
00000720  74 6f 20 74 75 6e 65 25  30 20 64 6f 0a 0d 20 20  |to tune%0 do..  |
00000730  20 24 28 20 6c 65 74 20  63 68 20 3d 20 74 75 6e  | $( let ch = tun|
00000740  65 25 69 0a 0d 0a 0d 20  20 20 20 20 20 74 65 73  |e%i....      tes|
00000750  74 20 27 31 27 20 3c 3d  20 63 68 20 3c 3d 20 27  |t '1' <= ch <= '|
00000760  37 27 20 74 68 65 6e 0a  0d 0a 0d 20 20 20 20 20  |7' then....     |
00000770  20 2f 2f 20 4f 63 74 61  76 65 20 6e 75 6d 62 65  | // Octave numbe|
00000780  72 20 2d 20 69 6e 69 74  69 61 6c 69 73 65 20 70  |r - initialise p|
00000790  69 74 63 68 2e 0a 0d 20  20 20 20 20 20 20 20 20  |itch...         |
000007a0  70 69 74 63 68 20 3a 3d  20 34 38 2a 28 63 68 2d  |pitch := 48*(ch-|
000007b0  27 30 27 29 20 2d 20 39  31 0a 0d 0a 0d 20 20 20  |'0') - 91....   |
000007c0  20 20 20 65 6c 73 65 20  74 65 73 74 20 27 61 27  |   else test 'a'|
000007d0  20 3c 3d 20 63 68 20 3c  3d 20 27 67 27 20 74 68  | <= ch <= 'g' th|
000007e0  65 6e 0a 0d 0a 0d 20 20  20 20 20 20 2f 2f 20 4e  |en....      // N|
000007f0  6f 74 65 20 28 71 75 61  76 65 72 29 20 2d 20 75  |ote (quaver) - u|
00000800  70 64 61 74 65 20 70 69  74 63 68 20 61 6e 64 20  |pdate pitch and |
00000810  6c 65 61 76 65 20 65 6e  76 65 6c 6f 70 65 20 61  |leave envelope a|
00000820  73 20 31 20 28 6f 72 20  33 29 2e 0a 0d 20 20 20  |s 1 (or 3)...   |
00000830  20 20 20 20 20 20 70 69  74 63 68 20 3a 3d 20 70  |      pitch := p|
00000840  69 74 63 68 20 2b 20 6e  6f 74 65 76 61 6c 21 28  |itch + noteval!(|
00000850  63 68 2d 27 61 27 29 0a  0d 0a 0d 20 20 20 20 20  |ch-'a')....     |
00000860  20 65 6c 73 65 20 74 65  73 74 20 27 41 27 20 3c  | else test 'A' <|
00000870  3d 20 63 68 20 3c 3d 20  27 47 27 20 74 68 65 6e  |= ch <= 'G' then|
00000880  0a 0d 0a 0d 20 20 20 20  20 20 2f 2f 20 4e 6f 74  |....      // Not|
00000890  65 20 28 63 72 6f 74 63  68 65 74 29 20 2d 20 75  |e (crotchet) - u|
000008a0  70 64 61 74 65 20 70 69  74 63 68 20 61 6e 64 20  |pdate pitch and |
000008b0  73 65 6c 65 63 74 20 65  6e 76 65 6c 6f 70 65 20  |select envelope |
000008c0  32 2e 0a 0d 20 20 20 20  20 20 24 28 20 70 69 74  |2...      $( pit|
000008d0  63 68 20 3a 3d 20 70 69  74 63 68 20 2b 20 6e 6f  |ch := pitch + no|
000008e0  74 65 76 61 6c 21 28 63  68 2d 27 41 27 29 0a 0d  |teval!(ch-'A')..|
000008f0  20 20 20 20 20 20 20 20  20 65 6e 76 6e 75 6d 62  |         envnumb|
00000900  65 72 20 3a 3d 20 32 0a  0d 20 20 20 20 20 20 24  |er := 2..      $|
00000910  29 0a 0d 0a 0d 20 20 20  20 20 20 65 6c 73 65 20  |)....      else |
00000920  74 65 73 74 20 63 68 20  3d 20 27 21 27 20 74 68  |test ch = '!' th|
00000930  65 6e 0a 0d 0a 0d 20 20  20 20 20 20 2f 2f 20 53  |en....      // S|
00000940  74 61 72 74 20 6f 66 20  62 61 72 20 73 6f 20 73  |tart of bar so s|
00000950  65 74 20 65 6e 76 65 6c  6f 70 65 20 33 20 66 6f  |et envelope 3 fo|
00000960  72 20 66 6f 6c 6c 6f 77  69 6e 67 20 6e 6f 74 65  |r following note|
00000970  2e 0a 0d 20 20 20 20 20  20 20 20 20 65 6e 76 6e  |...         envn|
00000980  75 6d 62 65 72 20 3a 3d  20 33 0a 0d 0a 0d 20 20  |umber := 3....  |
00000990  20 20 20 20 65 6c 73 65  0a 0d 0a 0d 20 20 20 20  |    else....    |
000009a0  20 20 2f 2f 20 41 73 73  75 6d 65 20 27 2b 27 2c  |  // Assume '+',|
000009b0  20 27 2d 27 20 6f 72 20  73 70 61 63 65 20 73 6f  | '-' or space so|
000009c0  20 61 64 6a 75 73 74 20  70 69 74 63 68 20 66 6f  | adjust pitch fo|
000009d0  72 20 73 68 61 72 70 20  6f 72 0a 0d 20 20 20 20  |r sharp or..    |
000009e0  20 20 2f 2f 20 66 6c 61  74 20 69 66 20 61 70 70  |  // flat if app|
000009f0  72 6f 70 72 69 61 74 65  20 74 68 65 6e 20 70 6c  |ropriate then pl|
00000a00  61 79 20 74 68 65 20 6e  6f 74 65 2e 0a 0d 20 20  |ay the note...  |
00000a10  20 20 20 20 24 28 20 74  65 73 74 20 63 68 20 3d  |    $( test ch =|
00000a20  20 27 2b 27 20 74 68 65  6e 0a 0d 20 20 20 20 20  | '+' then..     |
00000a30  20 20 20 20 20 20 20 70  69 74 63 68 20 3a 3d 20  |       pitch := |
00000a40  70 69 74 63 68 20 2b 20  34 0a 0d 20 20 20 20 20  |pitch + 4..     |
00000a50  20 20 20 20 65 6c 73 65  20 69 66 20 63 68 20 3d  |    else if ch =|
00000a60  20 27 2d 27 20 74 68 65  6e 0a 0d 20 20 20 20 20  | '-' then..     |
00000a70  20 20 20 20 20 20 20 70  69 74 63 68 20 3a 3d 20  |       pitch := |
00000a80  70 69 74 63 68 20 2d 20  34 0a 0d 0a 0d 20 20 20  |pitch - 4....   |
00000a90  20 20 20 20 20 20 73 6f  75 6e 64 76 65 63 21 31  |      soundvec!1|
00000aa0  20 3a 3d 20 65 6e 76 6e  75 6d 62 65 72 0a 0d 20  | := envnumber.. |
00000ab0  20 20 20 20 20 20 20 20  73 6f 75 6e 64 76 65 63  |        soundvec|
00000ac0  21 32 20 3a 3d 20 70 69  74 63 68 0a 0d 20 20 20  |!2 := pitch..   |
00000ad0  20 20 20 20 20 20 73 6f  75 6e 64 76 65 63 21 33  |      soundvec!3|
00000ae0  20 3a 3d 20 65 6e 76 6e  75 6d 62 65 72 20 3d 20  | := envnumber = |
00000af0  32 20 2d 3e 20 36 2c 20  33 20 2f 2f 20 64 75 72  |2 -> 6, 3 // dur|
00000b00  61 74 69 6f 6e 20 28 6c  6f 6e 67 65 72 20 66 6f  |ation (longer fo|
00000b10  72 20 63 72 6f 74 63 68  65 74 29 0a 0d 20 20 20  |r crotchet)..   |
00000b20  20 20 20 20 20 20 73 6f  75 6e 64 28 73 6f 75 6e  |      sound(soun|
00000b30  64 76 65 63 29 0a 0d 0a  0d 20 20 20 20 20 20 20  |dvec)....       |
00000b40  20 20 65 6e 76 6e 75 6d  62 65 72 20 3a 3d 20 31  |  envnumber := 1|
00000b50  20 20 20 20 2f 2f 20 72  65 73 65 74 20 65 6e 76  |    // reset env|
00000b60  65 6c 6f 70 65 20 6e 75  6d 62 65 72 20 74 6f 20  |elope number to |
00000b70  71 75 61 76 65 72 2e 0a  0d 20 20 20 20 20 20 24  |quaver...      $|
00000b80  29 0a 0d 20 20 20 24 29  20 20 20 20 20 20 20 20  |)..   $)        |
00000b90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 2f 2f  |              //|
00000ba0  20 62 61 63 6b 20 66 6f  72 20 6e 65 78 74 20 63  | back for next c|
00000bb0  68 61 72 61 63 74 65 72  0a 0d 0a 0d 20 20 20 2f  |haracter....   /|
00000bc0  2f 20 41 6c 6c 20 6e 6f  74 65 73 20 70 75 74 20  |/ All notes put |
00000bd0  69 6e 20 62 75 66 66 65  72 2e 20 57 61 69 74 20  |in buffer. Wait |
00000be0  75 6e 74 69 6c 20 74 68  65 79 20 68 61 76 65 20  |until they have |
00000bf0  62 65 65 6e 20 70 6c 61  79 65 64 0a 0d 20 20 20  |been played..   |
00000c00  2f 2f 20 62 65 66 6f 72  65 20 72 65 74 75 72 6e  |// before return|
00000c10  69 6e 67 20 74 6f 20 74  68 65 20 6d 65 6e 75 2e  |ing to the menu.|
00000c20  0a 0d 0a 0d 20 20 20 75  6e 74 69 6c 20 61 64 76  |....   until adv|
00000c30  61 6c 28 2d 36 29 20 3d  20 73 62 75 66 66 73 7a  |al(-6) = sbuffsz|
00000c40  20 6c 6f 6f 70 20 20 20  20 20 20 2f 2f 20 77 61  | loop      // wa|
00000c50  69 74 20 66 6f 72 20 74  75 6e 65 20 74 6f 20 65  |it for tune to e|
00000c60  6e 64 0a 0d 24 29 0a 0d  0a 0d 0a 0d 2f 2f 20 44  |nd..$)......// D|
00000c70  49 53 50 4e 4f 54 45 20  64 69 73 70 6c 61 79 73  |ISPNOTE displays|
00000c80  20 61 20 6e 6f 74 65 20  73 79 6d 62 6f 6c 20 69  | a note symbol i|
00000c90  6e 20 66 6c 61 73 68 69  6e 67 20 77 68 69 74 65  |n flashing white|
00000ca0  20 61 74 20 61 20 73 70  65 63 69 66 69 65 64 20  | at a specified |
00000cb0  78 20 70 6f 73 69 74 69  6f 6e 2e 0a 0d 0a 0d 61  |x position.....a|
00000cc0  6e 64 20 64 69 73 70 6e  6f 74 65 28 78 29 20 62  |nd dispnote(x) b|
00000cd0  65 0a 0d 24 28 20 6c 65  74 20 63 68 61 72 74 61  |e..$( let charta|
00000ce0  62 20 3d 20 74 61 62 6c  65 20 31 36 30 2c 31 36  |b = table 160,16|
00000cf0  30 2c 32 33 34 2c 32 32  38 2c 20 20 20 2f 2f 20  |0,234,228,   // |
00000d00  34 78 35 20 61 72 72 61  79 20 6f 66 20 67 72 61  |4x5 array of gra|
00000d10  70 68 69 63 73 20 63 68  61 72 73 0a 0d 20 20 20  |phics chars..   |
00000d20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000d30  20 20 20 20 31 34 31 2c  31 36 30 2c 32 33 34 2c  |    141,160,234,|
00000d40  31 36 30 2c 20 20 20 2f  2f 20 64 6f 75 62 6c 65  |160,   // double|
00000d50  20 68 65 69 67 68 74 0a  0d 20 20 20 20 20 20 20  | height..       |
00000d60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000d70  31 34 31 2c 31 36 30 2c  32 33 34 2c 31 36 30 2c  |141,160,234,160,|
00000d80  0a 0d 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |..              |
00000d90  20 20 20 20 20 20 20 20  20 31 36 30 2c 32 34 38  |         160,248|
00000da0  2c 32 35 34 2c 31 36 30  2c 0a 0d 20 20 20 20 20  |,254,160,..     |
00000db0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000dc0  20 20 31 36 30 2c 31 38  31 2c 32 33 34 2c 31 36  |  160,181,234,16|
00000dd0  30 2c 0a 0d 20 20 20 20  20 20 20 20 20 20 20 20  |0,..            |
00000de0  20 20 20 20 20 20 20 20  20 20 20 31 36 30 2c 31  |           160,1|
00000df0  37 31 2c 31 36 37 2c 31  36 30 0a 0d 20 20 20 66  |71,167,160..   f|
00000e00  6f 72 20 69 3d 30 20 74  6f 20 35 20 64 6f 0a 0d  |or i=0 to 5 do..|
00000e10  20 20 20 24 28 20 74 78  74 63 75 72 73 6f 72 28  |   $( txtcursor(|
00000e20  78 2c 20 33 2b 69 29 20  20 20 20 2f 2f 20 70 6f  |x, 3+i)    // po|
00000e30  73 69 74 69 6f 6e 20 63  68 61 72 61 63 74 65 72  |sition character|
00000e40  20 6f 6e 20 6c 69 6e 65  20 33 0a 0d 20 20 20 20  | on line 3..    |
00000e50  20 20 77 72 62 69 6e 28  31 33 36 29 20 20 20 20  |  wrbin(136)    |
00000e60  20 20 20 20 20 20 20 2f  2f 20 66 6c 61 73 68 69  |       // flashi|
00000e70  6e 67 0a 0d 20 20 20 20  20 20 77 72 62 69 6e 28  |ng..      wrbin(|
00000e80  31 35 31 29 20 20 20 20  20 20 20 20 20 20 20 2f  |151)           /|
00000e90  2f 20 67 72 61 70 68 69  63 20 77 68 69 74 65 0a  |/ graphic white.|
00000ea0  0d 20 20 20 20 20 20 66  6f 72 20 6a 3d 34 2a 69  |.      for j=4*i|
00000eb0  20 74 6f 20 34 2a 69 2b  33 20 64 6f 0a 0d 20 20  | to 4*i+3 do..  |
00000ec0  20 20 20 20 20 20 20 77  72 62 69 6e 28 63 68 61  |       wrbin(cha|
00000ed0  72 74 61 62 21 6a 29 0a  0d 20 20 20 20 20 20 77  |rtab!j)..      w|
00000ee0  72 62 69 6e 28 31 33 37  29 20 20 20 20 20 20 20  |rbin(137)       |
00000ef0  20 20 20 20 2f 2f 20 73  74 65 61 64 79 0a 0d 20  |    // steady.. |
00000f00  20 20 24 29 0a 0d 24 29  0a 0d 0a 0d 0a 0d 2f 2f  |  $)..$)......//|
00000f10  20 44 4f 44 49 53 50 4c  41 59 20 73 65 74 73 20  | DODISPLAY sets |
00000f20  75 70 20 74 68 65 20 64  69 73 70 6c 61 79 2e 0a  |up the display..|
00000f30  0d 0a 0d 61 6e 64 20 64  6f 64 69 73 70 6c 61 79  |...and dodisplay|
00000f40  28 29 20 62 65 0a 0d 24  28 20 6d 6f 64 65 28 37  |() be..$( mode(7|
00000f50  29 0a 0d 20 20 20 66 6f  72 20 69 20 3d 20 30 20  |)..   for i = 0 |
00000f60  74 6f 20 31 20 64 6f 20  20 20 20 20 20 20 2f 2f  |to 1 do       //|
00000f70  20 64 6f 75 62 6c 65 20  68 65 69 67 68 74 20 74  | double height t|
00000f80  69 74 6c 65 0a 0d 20 20  20 24 28 20 74 78 74 63  |itle..   $( txtc|
00000f90  75 72 73 6f 72 28 31 30  2c 20 69 2b 34 29 0a 0d  |ursor(10, i+4)..|
00000fa0  20 20 20 20 20 20 77 72  69 74 65 73 28 22 2a 78  |      writes("*x|
00000fb0  38 44 2a 78 38 31 2a 78  39 44 2a 78 38 36 4d 20  |8D*x81*x9D*x86M |
00000fc0  55 20 53 20 49 20 43 20  20 2a 78 39 43 22 29 0a  |U S I C  *x9C").|
00000fd0  0d 20 20 20 24 29 0a 0d  20 20 20 64 69 73 70 6e  |.   $)..   dispn|
00000fe0  6f 74 65 28 31 29 3b 20  64 69 73 70 6e 6f 74 65  |ote(1); dispnote|
00000ff0  28 32 39 29 20 20 20 20  20 20 20 20 2f 2f 20 6e  |(29)        // n|
00001000  6f 74 65 20 73 79 6d 62  6f 6c 73 0a 0d 20 20 20  |ote symbols..   |
00001010  74 78 74 63 75 72 73 6f  72 28 31 2c 20 31 30 29  |txtcursor(1, 10)|
00001020  0a 0d 20 20 20 66 6f 72  20 69 20 3d 20 30 20 74  |..   for i = 0 t|
00001030  6f 20 31 34 20 64 6f 0a  0d 20 20 20 24 28 20 77  |o 14 do..   $( w|
00001040  72 62 69 6e 28 31 32 39  20 2b 20 28 69 20 72 65  |rbin(129 + (i re|
00001050  6d 20 33 29 29 20 20 20  20 20 20 20 20 2f 2f 20  |m 3))        // |
00001060  73 65 6c 65 63 74 20 6f  6e 65 20 6f 66 20 74 68  |select one of th|
00001070  72 65 65 20 63 6f 6c 6f  75 72 73 0a 0d 20 20 20  |ree colours..   |
00001080  20 20 20 77 72 69 74 65  73 28 22 4d 55 53 49 43  |   writes("MUSIC|
00001090  22 29 0a 0d 20 20 20 20  20 20 77 72 62 69 6e 28  |")..      wrbin(|
000010a0  31 30 29 20 20 20 20 20  20 20 20 20 20 20 20 20  |10)             |
000010b0  20 20 20 20 20 20 20 20  2f 2f 20 63 75 72 73 6f  |        // curso|
000010c0  72 20 64 6f 77 6e 20 74  68 65 6e 20 34 20 6c 65  |r down then 4 le|
000010d0  66 74 0a 0d 20 20 20 20  20 20 66 6f 72 20 6a 20  |ft..      for j |
000010e0  3d 20 31 20 74 6f 20 34  20 64 6f 20 77 72 62 69  |= 1 to 4 do wrbi|
000010f0  6e 28 38 29 0a 0d 20 20  20 24 29 0a 0d 20 20 20  |n(8)..   $)..   |
00001100  74 78 74 63 75 72 73 6f  72 28 30 2c 20 32 33 29  |txtcursor(0, 23)|
00001110  20 20 20 20 20 20 20 20  2f 2f 20 6c 65 61 76 65  |        // leave|
00001120  20 63 75 72 73 6f 72 20  61 74 20 65 6e 64 20 6f  | cursor at end o|
00001130  66 20 73 63 72 65 65 6e  0a 0d 24 29 0a 0d 2e 0a  |f screen..$)....|
00001140  0d 0a 0d                                          |...|
00001143
EXMP2B.m0
EXMP2B.m1
EXMP2B.m2
EXMP2B.m4
EXMP2B.m5