A downloadable tool

Instructions:

Have you ever wanted to use the SOUND command in MSX BASIC, but didn't know how?

Well, you're in luck because MSX Sound Tool X makes using the SOUND command a piece of cake!

To begin, type LOAD"SOUND10.BAS", and then RUN the program.

Use the UP and DOWN arrow keys to cycle through the different sound settings.

Use the LEFT and RIGHT arrow keys to change the values for each sound setting.

To play your current sound, press the SPACE key.

If the sound repeats or is irritating, press the ESC key to stop the current sound.

MSX Sound Tool X includes 8 preset sounds. Press the P key to cycle through the sound presets.

If you're feeling lucky, press the R key to generate a random sound.

When you have a sound that you'd like to keep, press the S key to save your sound.

When you press S, you will be taken to a new screen displaying the BASIC instruction to play your sound.

To store your sound into memory as a new program line, press the RETURN key.

A new program line will be generated everytime you press S, so you don't need to worry about renumbering the sound output's line number before you hit return.

To return to the main screen, type RUN.


SOUND Tool X Explanation

Line 1:

Set up the screen, then define variables as integers (for speed).

Seed the random variable, then dimension a few arrays.

B$ holds the text for the sound type display.

C$ holds the waveform shapes that will be displayed.

the 3 vpokes edit the - and _ characters slightly.

Print the name of the app onscreen.

The FOR loop pokes two rows of the underscore character into the name table.


Line 2:

Continue the FOR loop from line 1.

The next FOR loop redefines the >, /, and \ characters.

The last FOR loop fills array C() with the values for the waveforms.

The data statement includes the data for the FOR loops.


Line 3:

The first FOR loop Prints the text for the sound settings.

The next FOR loop loads some data into array A(), this data is used to set the max values for the sound settings and fills array B() with the perameters for the different SOUND play values.

Lastly, finish up placing text on the screen and then jump to line 5 as to skip some stuff in line 4 and finish up the screen draw by filling in some default values.


Line 4:

C is used to move the cursor up and down.

Set K$ to whatever key is pressed.

When you press the SPACE KEY, A(0) is set to val H. H is the value for the current mixer setting: Tone, Noise and which channels are in use (For this application we are using only channel A). A(14) gets set to val W. W is the value for the waveform.

The FOR loop plays the sound, pulling values from A() and C().

A(0) is reset to it's original value stored in val G.

A(14) is reset to it's original value stored in val V.

If the R key is pressed, gosub to line 10 to erase the text for the sound preset and then randomize all sound values with the FOR loop. Gosub to 8 to print the new values to the screen.

If the P key is pressed, gosub to line 7 to load and print the preset values.

If none of the arrow keys are pressed, then set val Y to 0 (Y is a "debounce" value for the arrow cursor)


Line 5:

If the ESCAPE key is pressed then BEEP, this clears all sound values. (You could also do "DEFUSR=&H90:A=USR(0)", but BEEP is much shorter.)

If the S key is pressed then poke +1 to an unused location in RAM. (this keeps the value in memory when the program is run again so you don't overwrite your saved sounds). Gosub to 9 to draw the save screen and print out the code for your current sound.

If none of the arrow keys are pressed and C=2 (Up or Down has been pressed), then set Y to 1 as to reset the up / down debounce. Next, erase the arrow cursor and set value B to the new Y position of the arrow and then print the arrow in the new position.

If the either the left of right arrow key is pressed, then set SX to either 1 or -1 then GOSUB to line 8 to update the sound values.

Next, set Z to 1 so the instruction at line 10 will be true then GOSUB to 10 to erase the text for the preset sound.


Line 6:

GOTO 4 to continue the main game loop.

DATA for the main screen text and values that were read in line 3


Line 7:

This line is for the "Preset Sound" command.

Start by clearing SX so that the sound values don't get altered when gosub-ing to line 8 later.

Store val B to B2 temporarily, then read the preset sound data and gosub to 8 to update the values on screen.

Read the name of the preset sound, GOSUB to 10 to erase the old preset name and then print the new preset name.

Restore B, add 1 to P (used to record which preset sound we are on).

If we reach the end of the preset sound data then reset the data.

Some data for preset sounds.


Line 8:

This line updates and prints the sound values.

First we update whichever sound value was incremented / decremented: SX is the inc/dec value, A(B+1) holds the MOD value to fix / set rollover values.

Print the updated value + a couple blank spaces to overwrite any long number that rolled over to 0.

H is the value that will be used for SOUND7.  Copy the val at A(0) to val G. Copy the values at A(14) and B(A(14) to V and W.

If B=0 (Sound Type is selected) then print the correct text for the sound type and then return to the main loop.

Otherwise if B=14 (Envelope Shape is selected) then print the correct text for the envelope shape and then return to the main loop.

Otherwise, return to the main loop

A little bit of Preset sound data


Line 9:

This is part 1 of the Save routine.

Basically, this just clears the screen and prints some text.

Some more DATA for the preset sounds


Line 10:

The first part is used as a GOSUB to clear the text area for the preset sound. Z is only set to 1 when jumping to this line as a GOSUB.

If Z=0 then print out the BASIC code used to play the sound.

The line number for your new line of BASIC is stored in ram at 49163. This lets you RUN the program again and save another sound to a different line number every time.

Locate the cursor just above the new line of BASIC so that all you have to do is press RETURN to save it into memory.

Data for the last of the preset sounds.


1 SCREEN1,0,0:WIDTH32:KEYOFF:DEFINTA-Z:A=RND(-TIME):DIMA(16):DIMB(7):DIMC(7):B$="Tone NoiseBoth ":C$="\_____/_____/-----\-----/\/\/\\/\/\///////\\\\\\":VPOKE362,255:VPOKE363,0:VPOKE766,255:LOCATE 7,0:PRINT"=MSX Sound Tool X=":FORI=6176TO6207:VPOKEI,45
2 VPOKEI+512,95:NEXT:FORI=0TO7:READA:VPOKE736+I,A:READA:VPOKE376+I,A:READA:VPOKE496+I,A:NEXT:FORI=0TO7:READA:C(I)=A:NEXT:DATA0,0,24,0,0,28,32,2,254,16,4,255,8,8,254,4,16,28,2,32,24,0,0,0,7,8,0,1,6,11,12,13
3 FORI=0TO7:READA$:LOCATE2,2+I*2:PRINTA$:NEXT:FOR I=0TO7:READA:A(I*2+1)=A:READA:B(I)=A:NEXT:LOCATE9,18:PRINT"*Command Keys*":FORI=0TO4:LOCATE1,19+I:READA$:PRINTA$;:LOCATE6,19+I:READA$:PRINTA$;:NEXT:GOSUB7:B=-2:C=2:GOTO5
4 C=STICK(0)-3:K$=INKEY$:IFSTRIG(0)THENA(0)=H:A(14)=W:FORI=0TO7:SOUNDC(I),A(I*2):NEXT:A(0)=G:A(14)=V:ELSEIFK$="r"THENZ=1:GOSUB10:SX=0:B2=B:FORB=0TO14STEP2:A(B)=-1*(B<>2)*(RND(1)*256)+(B=2)*-16:GOSUB8:NEXT:B=B2:ELSEIFK$="p"THENGOSUB7:ELSEIFC=-3THENY=0
5 IFK$=CHR$(27)THENBEEP:ELSEIFK$="s"THENPOKE49163!,PEEK(49163!)+1:GOTO9:ELSEIFY=0ANDABS(C)=2THENY=1:LOCATE0,2+B:PRINT" ":B=(16+B+C)MOD16:LOCATE0,2+B:PRINT">":ELSEIF(STICK(0)+1)MOD4=0THENSX=SGN(STICK(0)-4):GOSUB8:Z=1:GOSUB10
6 GOTO4:DATASound Type,Volume,Tone Fine, Tone Coarse,Noise Frequency,Duration Fine,Duration Coarse,Envelope Shape,3,0,17,4,256,13,16,11,32,14,256,10,256,12,8,8,SPACE,=Play Sound,ESC,=Stop Sound,R,=Randomize Sound,P,=Preset Sound*,S,=SAVE
7 SX=0:B2=B:FORB=0TO14STEP2:READA:A(B)=A:GOSUB8:NEXT:READA$:Z=1:GOSUB10:LOCATE21,22:PRINTA$;:B=B2:P=(P+1)MOD8:IFP=0THENRESTORE7:RETURN:DATA0,16,98,0,14,64,19,0,Ding,0,16,130,3,6,20,6,0,Pong,2,16,165,3,5,25,64,6,Electric,1,16,206,11,20,34,8,1,Swift,1,16
8 A(B)=(A(B+1)+(A(B)-1*SX))MODA(B+1):LOCATE18,2+B:PRINTSTR$(A(B))+"  ":H=190+((A(0)>0)*6)-A(0):G=A(0):W=B(A(14)):V=A(14):IFB=0THENLOCATE25,2+B:PRINTMID$(B$,1+A(B)*5,5):RETURNELSEIFB=14THENLOCATE25,2+B:PRINTMID$(C$,1+A(B)*6,6):RETURNELSERETURN:DATA175,12
9 CLS:A(0)=H:LOCATE10,0:PRINT"BASIC output:":FORI=6208TO6239:VPOKEI,45:VPOKEI+256,45:NEXT:LOCATE5,13:PRINT"Press RETURN to save":LOCATE5,16:PRINT"Type RUN to continue":A(14)=W:DATA31,4,1,5,Engine,1,16,167,10,25,138,0,6,Propeller,1,16,147,1,16,105,4,0
10 IFZ=1THENLOCATE21,22:PRINT"           ";:Z=0:RETURN:ELSELOCATE0,5:PRINTMID$(STR$((PEEK(49163!)+1)*10),2,3)+" ";:FORI=0TO7:PRINT"SOUND"+MID$(STR$(C(I)),2,3)+","+MID$(STR$(A(I*2)),2,3)+":";:NEXT:LOCATE0,4:END:DATAGunshot,1,16,98,7,30,0,100,0,Explode



Download

Download
Code Explanation.txt 4 kB
Download
Instructions.txt 1 kB
Download
Listing.txt 2 kB
Download
soundx.dsk 720 kB

Comments

Log in with itch.io to leave a comment.

very good