TUNE-A-PATE

from Your Sinclair #10 (Oct.1986)



You want to add tasty machine code music to your own games?

Well, open a tin of Tune-A-Fish in the company of this

month's Master Chef Benny Modig, and see how easy it can be.





If you ever thrilled to the music on your Spectrum computer

games, and wondered if your games could sound as tuneful,

then this is the recipe for yoo-hoo! You see, the reason

you're so incredibly gripped, excited and thrilled by the

music in professionally produced games is this: the tunes

are stored in machine code in a space in the computer's

memory and riffed through jolly fast by a miniature reading

routine.



Contained within this awfully short program are all the

necessary doobries to add your music to your own games

without interrupting the action! You can compile the code of

your music to anywhere in memory, so that it fits in with

any programming needs. Also, it's only 189 bytes long, so

it'll work with quite long programs.



The drawback of using sound with Spectrum programs has

always been that in order to generate the sound, the

computer has to stop processing. This lasts for the duration

of the sound which in some cases could be a whole second,

making arcade action very slow indeed. The great strength of

this program is that it holds up the program in operation

for only about (set at top speed) 0.01 of a second to make

your sound effects and musical tones. So, this is one dish

you can't afford not to serve in your Spectrum!





WHAT TO DO



First wash your hands and lay out all the ingredients on a

clean work surface. Spread a little butter on the bread and

pile Tuna on one slice. Press the other slice on top of all

this and eat. Hurry up, there's work to do! Nice? You bet.

Okay, down to business ...



Type in the program as listed (a Tried'n'Tested product) and

save it to tape as SAVE "TUNE-A-FISH' LINE 1. Now, all you

need to add music to your programs is together in one

ready-to-serve portion. After running the program you are

faced with the main menu.





STARTERS



C       Changes the speed of the piece of music

O       Gets you out of the program

S       Saves your compiled tune

L       Listen to your tune

K       Compiles your tune to mega quick code





SERVING SUGGESTIONS



Mmmm. There are so many tasty ways you can enjoy your

Tune-A-Pate. There are a couple of limitations to the

program, but with careful programming and a bit of

forethought, these problems can be overcome.



The number of notes you can compile at one time is limited

to 17 maximum. If the tune you want to compile is longer

than this, and what tune isn't, you can do the following:



Put the tune in groups of 17 notes in DATA statements at the

beginning, in the same way as the demo tunes, with a REM

command before them. Remove the REM from a line and compile

it to your first block of memory. Then put the REM back and

remove the next line's REM and compile that to the next

address after the last piece you compiled. (Got that?)

Repeat the procedure until all your notes have been

compiled. You call back the routine with LET I=USR adr1: LET

I=USR adr2: ... and so forth, where adr is the address where

you put the notes.



Tune-A -Pate is so versatile. With thoughtful programming,

and a little knowledge of the BEEP command, you can not only

program tunes into your games, but also superfast sound

effects which don't interrupt the action. Now there's a

herring sandwich.





Lines 2-4       These are the demo tunes stored in REM statements

                to illustrate the method of inputting notes to the

                compiler.

Line  5005      Here the SAVE routine is shown as a microdrive routine,

                but if you want it to work with tape, simply delete

                the *"M";1; parts of the line.

Line  6000      The Listen routine, including a moving asterisk to 

                show that the delay is always the same.

Line  8901      The machine code interrupt and controller program.

Lines 9002-9003 A table of note frequencies to make the notes you hear

                closer to real musical pitches.





--

Another Fine Product transcribed by:

Jim Grimwood (jimg@globalnet.co.uk), Weardale, England

--

