★ APPLICATIONS ★ DIVERS ★ RSX BACKGROUND MUSIC (YOUR COMPUTER) ★ |
RSX Background Music (Your Computer) | Applications Divers |
Many popular video games nowadays have music ringing in the background during play. The Amstrad CPC-464 computer has some excellent facilities for, sound generation but attempting to add background music to a Basic program using the Every instruction generally gives poor results with the game being slowed down considerably. The assembly language program presented here allows interrupt driven background music to be added to Basic programs through the use of some simple RSX-Resident System extension-commands. It also allows the us of one, two or all three sound channels. The following commands are provided. Note that each one must be preceded by a vertical bar (Shift ‘@') symbol. A parameter enclosed in square brackets is optional. (1). MUSICON ,t, a1 (,a2) (,a3) — turn on music, where t is the tempo (the length in fiftieths of a second, of the shortest available note) and al,a2 and a3 are two less than the addresses of the data for channels 1,2 and 3 respectively. (2). MUSICOFF — turn off music. (3). VOLUME v, 1 (,v2) (,v3) — set for channel (s), where vl, v2 and v3 are the respective amplitudes of channels 1,2 and 3. (4). PAUSE — stop playing music. (5). CONTINUE — continue playing music after pausing. To enter the program, you can either enter and assemble the source code — listing 1 — using an assembler. I have used Devpac but any good one should do). Or if you do not have an assembler I have provided a Basic loader program — listing 2 — which should be typed in and Run to store the code in memory. Once the code is in memory, it can be saved on tape (or disc) using the command SAVE “MUSIC”, B,&A000,&2A0 (enter) To make the computer recognise the new commands the instruction CALL &A1C5 should be given. At this point the program can be tested by entering and Running listing 3 which tells the computer to repeatedly play all the notes available until a Musicoff command is given. Any program using the extension commands should include the following line to load the code and log-on the commands MEMORY &9FFF: LOAD “!MUSIC”:CALL&A1C5 The data for the music to be played through a channel is arranged as follows:-byte 1 —duration of note 1 (1-127), byte 2 (upper nybble) — note 1 octave (0-5), byte 2 (lower nybble) — note 1 number (0-11), byte 3 — duration of note 2, byte 4 (upper nybble) — note 2 octave, byte 4 (lower nybble) — note 2 number....... , 0 Once the music playing routine discovers the 0 in place of a duration number it then loops back to the beginning again. If bit 7 of the duration number is set (just add 128), then the note is a rest otherwise 1 is the shortest note available, 2 is twic as long, 3 is three times as long etc. The octaves available correspond to octaves —2 to + 3 shown in the CPC-464 manual appendix VII and in the firmware manual appendix VIII. e.g. bytes 2,52 define a note of duration 2, octave 3, note 4; 129, 0 define a rest of duration 1. A simple formula for working ot the second byte of a note is therefore: byte stored = 16*octave + noteIf you do not wish to type in the program I can supply copies of it on cassette for £4 each. Please include a 24 pence SAE. Write to: M.B.L. Dunlop, 19 Droridge, Dartington, Totnes, Devon, TQ9 6JG. YR
|