' ************************************************************************
' *              YAMAHA PSS-480 VOICE AND STYLE CHANGER                  *
' *                                                                      *
'                by Michael L.Silverstein (12/90)                        *
' *                                                                      *
' ************************************************************************
'
rez=XBIOS(4)
IF rez=0 OR rez=2 THEN
  ALERT 1,"Medium Resoulution Only!",1,"sorry",b
  END
ENDIF
'
SETCOLOR 0,7,0,7        !Violet Background color
DEFMOUSE 3              !Pointing hand for mouse
voicechange=&HC0        !MIDI program change
stylechange=&HCF        !MIDI rhythm change
mididata=0              !initialize voice/style data
midimode=0              !initialize select mode
midi$=""                !initialize MIDI text string
n=0                     !initialize MIDI array subscript
interval=0              !initialize time interval between presets
presets=0               !initialize # of presets
presetno=0              !initialize preset counter
viewbutton=1            !initialize view selection button
selecionbutton=1        !initialize select button
DIM a$(100)             !initialize MIDI text string array
DIM voice(100)          !initialize voice preset array
DIM style(100)          !initialize style preset array
DIM presetflag(100)     !initialize preset flag array
'
' Set up for GEM main menu
'
DIM m$(25)
m$(0)=" Desk "
m$(1)=" About Program "
m$(2)="-----------------------"
m$(3)="1"
m$(4)="2"
m$(5)="3"
m$(6)="4"
m$(7)="5"
m$(8)="6"
m$(9)=""
m$(10)="Menus"
m$(11)="Voice Menu 1"
m$(12)="Voice Menu 2"
m$(13)="Style Menu 1"
m$(14)="Style Menu 2"
m$(15)=""
m$(16)="Execute"
m$(17)="Make Selections"
m$(18)="View Selections"
m$(19)="Play Tune"
m$(20)="Quit Yamaha PSS-480"
m$(21)=""
m$(22)="Help"
m$(23)="Menus"
m$(24)="Execute"
'
CLS
aboutyam
MENU m$()
ON MENU GOSUB main
DO
  ON MENU
LOOP
'
PROCEDURE main          !Main Menu loop
  button=MENU(0)
  MENU OFF
  IF button=MENU(2) THEN
    aboutyam            !Display dialog box
  ENDIF
  IF button=11 THEN
    voice1              !Draw and execute Screen 1
  ENDIF
  IF button=12 THEN
    voice2              !Draw and execute Screen 2
  ENDIF
  IF button=13 THEN
    style1              !Draw and execute Screen 3
  ENDIF
  IF button=14 THEN
    style2              !Draw and execute Screen 4
  ENDIF
  IF button=17 THEN
    IF selecionbutton>1 THEN
      CLS
      MENU m$()
      DEFTEXT 1,1,0,14    !Text=red,bold,left-right,small script
      message$="You have already made your selections.  Press Esc to Play tune"
      TEXT 20,100,message$
      DO UNTIL INKEY$=CHR$(27)
      LOOP
      playselect
    ELSE
      midimode=1          !set selection mode=ON
      presetno            !get # of presets
      INC selecionbutton
    ENDIF
  ENDIF
  IF button=18 THEN
    IF viewbutton>1 THEN
      CLS
      MENU m$()
      DEFTEXT 1,1,0,14    !Text=red,bold,left-right,small script
      message$="You have already made your selections.  Press Esc to Play tune"
      TEXT 20,100,message$
      DO UNTIL INKEY$=CHR$(27)
      LOOP
      playselect
    ELSE
      summarize         !display current voice and rhythm preset selections
      INC viewbutton
    ENDIF
  ENDIF
  IF button=19 THEN
    playselect          !play all preset selections based on interval
  ENDIF
  IF button=20 THEN
    SETCOLOR 0,7,7,7    !Reset to default GEM colors
    END                 !Quit and return to GEM
  ENDIF
  IF button=23 THEN
    helpmenus
  ENDIF
  IF button=24 THEN
    helpexecute
  ENDIF
RETURN
'
PROCEDURE aboutyam      !Dialog Box describing this program
  lx=100                !Note:GFA Companion created most of this
  rx=539
  ty=20
  by=189
  '
  '
  SGET tempuse$
  DIM linstyle%(12),credline$(12)
  linstyle%(0)=1
  linstyle%(1)=1
  linstyle%(2)=1
  linstyle%(3)=0
  linstyle%(4)=0
  linstyle%(5)=0
  linstyle%(6)=0
  linstyle%(7)=0
  linstyle%(8)=0
  linstyle%(9)=0
  linstyle%(10)=0
  linstyle%(11)=0
  linstyle%(12)=0
  credline$(1)="         By Michael Silverstein"
  credline$(2)="       Written with GFA Basic 3.07"
  credline$(3)=""
  credline$(4)="Left Click to select Voice or Rhythm."
  credline$(5)="Right Click to change Menus."
  credline$(6)="Use 'Execute' to Automate Selections!"
  credline$(7)=""
  credline$(8)=""
  credline$(9)=""
  credline$(10)=""
  credline$(11)=""
  credline$(12)=""
  DEFFILL 0,2,8
  DEFLINE 1,2
  @aboutyam.lstgrowbox(lx,ty,10,10,lx,ty,rx-lx,by-ty)
  PBOX lx,ty,rx,by
  BOX lx,ty,rx,by
  DEFLINE 1,1
  BOX lx+5,ty+2,rx-5,by-2
  DEFTEXT 1,linstyle%(0),0,13
  offset=22
  TEXT lx+55,ty+20,"       Yamaha PSS480 Voice & Rhythm Changer"
  FOR x=1 TO 3
    DEFTEXT 1,linstyle%(x),
    TEXT lx+55,(ty+25+(x)*offset),credline$(x)
  NEXT x
  offset=15
  FOR x=4 TO 12
    DEFTEXT 1,linstyle%(x),0,8
    TEXT lx+25,(ty+25+(x)*offset),credline$(x)
  NEXT x
  DEFTEXT 1,1,0,6
  TEXT lx+182,by-9,"Continue"
  DEFLINE 1,2
  BOX lx+175,by-19,rx-186,by-4
  REPEAT
    junk$=INKEY$
    k=MOUSEK
    x=MOUSEX
    y=MOUSEY
  UNTIL k=1 AND x>lx+175 AND x<rx-186 AND y>by-19 AND y<by-4 OR junk$<>""
  '
  DEFFILL 1,2,8
  PBOX lx+175,by-19,rx-186,by-4
  ERASE linstyle%()
  ERASE credline$()
  SPUT tempuse$
  CLR tempuse$,junk$
  @aboutyam.lstshrinkbox(lx,ty,20,5,lx,ty,rx-lx,by-ty)
RETURN
'
'
' These are the GEM¿ GRAF_GROWBOX & GRAF_SHRINKBOX Routines
' Init stands for Initial(X,Y,Height) and Fin stands for Final(X,Y,Height)
PROCEDURE aboutyam.lstgrowbox(init_x%,init_y%,init_w%,init_h%,fin_x%,fin_y%,fin_w%,fin_h%)
  DPOKE GINTIN,init_x%
  DPOKE GINTIN+2,init_y%
  DPOKE GINTIN+4,init_w%
  DPOKE GINTIN+6,init_h%
  DPOKE GINTIN+8,fin_x%
  DPOKE GINTIN+10,fin_y%
  DPOKE GINTIN+12,fin_w%
  DPOKE GINTIN+14,fin_h%
  GEMSYS 73
RETURN
PROCEDURE aboutyam.lstshrinkbox(fin_x%,fin_y%,fin_w%,fin_h%,init_x%,init_y%,init_w%,init_h%)
  DPOKE GINTIN,fin_x%
  DPOKE GINTIN+2,fin_y%
  DPOKE GINTIN+4,fin_w%
  DPOKE GINTIN+6,fin_h%
  DPOKE GINTIN+8,init_x%
  DPOKE GINTIN+10,init_y%
  DPOKE GINTIN+12,init_w%
  DPOKE GINTIN+14,init_h%
  GEMSYS 74
RETURN
'
' ****************************************************************************
' The Next four procedures implement the 4 display screens featuring all     *
' possible voices and styles for the Yamaha-PSS480 Synthesizer.  Each screen *
' displays a 12 X 5 matrix of rectangles representing all the instruments    *
' and rhythms(since there are at least 100 for each, 2 screens are need for  *
'  each).  The items in the rectangles are of type string and listed in DATA *
' statements. The x1,x2,y1,y2 values represent the coordinates for each      *
' rectangle.  A LOOP WITHIN A LOOP Structure is used to create the boxes.    *
'                                                                            *
' The Graphics for the rectangle are initialized to a filled bit pattern     *
' with normal medium resolution text in transparent mode.                    *
'                                                                            *
' Once the user selects 1 of the 4 screens from the Gem Menus a REPEAT UNTIL *
' loop is used with 6 FOR NEXT loops inside.  This time the count            *
' value represents the corresponding MIDI preset # for voice or style        *
' on which screen is used.  The loop is exited (in order to display another  *
' screen or quit) via the right mouse button.                                *
'                                                                            *
' If Select mode = ON, then the preset #, and text will be saved in the      *
' appropriate array instead of being sent to the synthesizer.                *
' ****************************************************************************
'
PROCEDURE voice1
  '
  mididata=1                    !initialize for voicedata
  RESTORE voices1               !Point to DATA items
  DEFTEXT 2,1,0,6               !Text=red,bold,left-right,small script
  DEFFILL ,1                    !bitpattern=filled
  GRAPHMODE 2                   !transparent mode
  '
  x1=10                         !initialize rectangle coordinates
  y1=15
  x2=125
  y2=28
  FOR i=1 TO 5                  !create column display
    IF i>1 THEN
      x1=x1+120                 !set up next column
      x2=x2+120
      y1=15
      y2=28
    ENDIF
    FOR j=1 TO 12               !create row display
      READ midi$                !Get text
      createmidibutton          !Draw the rectangle
    NEXT j
  NEXT i
  '
  voices1:
  DATA Synth Brass,Jazz Organ,Pipe Organ 1,Piano 1,Harpsichord 1
  DATA Elec Piano 1,Celesta,Vibraphone,Marimba 1,Steel drum 1,Violin 1,Cello
  DATA Jazz Guitar,Rock Guitar 1,Wood Bass 1,Trumpet,Trombone,Horn,Soprano Sax
  DATA Clarinet,Flute,Oboe,Harmonica,Whistle
  DATA Music Box,Honky-Tonk,Toy Piano,Trans Organ,Tremolo Organ,Church Organ
  DATA Funky Clavi,Accordion,Glokenspiel,Hawaii Guitar,Banjo,Bowed Bass
  DATA Acous Guitar,Harp,Picked Bass,Slap Bass,Ukelele,Strings,Alpenhorn
  DATA Bagpipe,Mute Trumpet,Tenor Sax,Jug,Panflute
  DATA Ice Block,Reed Organ,Elec Organ,Pipe Organ 2,Piano 2,Harpsichord 2
  DATA Elec Piano 2,Glass Celesta,Bandoneon,Street Organ,Synth Bass,Marimba 2
  '
  REPEAT
    '
    RESTORE voices1             !point to first DATA item
    '
    x1=10                       !1st column coordinates
    y1=15
    x2=125
    y2=28
    '
    FOR i=1 TO 12               !send voices from 1st column
      sendmidi
    NEXT i
    '
    x1=130                      !2nd column coordinates
    y1=15
    x2=245
    y2=28
    '
    FOR i=13 TO 24              !send voices from 2nd column
      sendmidi
    NEXT i
    '
    x1=250                      !3rd column coordinates
    y1=15
    x2=365
    y2=28
    '
    FOR i=25 TO 36              !send voices from 3rd column
      sendmidi
    NEXT i
    '
    x1=370                      !4th column coordinates
    y1=15
    x2=485
    y2=28
    '
    FOR i=37 TO 48              !send voices from 4th column
      sendmidi
    NEXT i
    '
    x1=490                      !5th column coordinates
    y1=15
    x2=605
    y2=28
    '
    FOR i=49 TO 60              !send voices from 5th column
      sendmidi
    NEXT i
    '
    i=1                         !reset counter and preset #
    PAUSE 15                    !prevent mouse bounce
    EXIT IF presetno>presets    !don't continue selections if > preset #
    '
  UNTIL MOUSEK=2                !exit for right mouse button
  '
  RESTORE voices1               !point to 1st DATA item
  '
RETURN
'
PROCEDURE voice2
  '
  mididata=1                    !initialize for voicedata
  RESTORE voices2               !Point to DATA items
  DEFTEXT 2,1,0,6               !Text=red,bold,left-right,small script
  DEFFILL ,1                    !bitpattern=filled
  GRAPHMODE 2                   !transparent mode
  '
  x1=10                         !initialize rectangle coordinates
  y1=15
  x2=125
  y2=28
  FOR i=1 TO 5                  !create column display
    IF i>1 THEN
      x1=x1+120                 !set up next column
      x2=x2+120
      y1=15
      y2=28
    ENDIF
    FOR j=1 TO 12               !create row display
      READ midi$                !Get text
      createmidibutton          !Draw the rectangle
    NEXT j
  NEXT i
  '
  voices2:
  DATA Steel Drum 2,Chimes,Tubular Bells,Hand Bell,Carillon,Synth Tom,Timpani
  DATA Violin 2,Rock Guitar 2,Tremolo Guitar,Rock Guitar 3,Pedal Guitar
  DATA 12 Strings ,Classic Guitar,Mandolin,Sitar,Koto,Shamisen,Jamisen
  DATA Mute Bass,Elec Bass,Wood Bass 2,Elec Trumpet,Wow Trumpet,Tuba,Alto Sax
  DATA Bass Clarinet,Bassoon,Recorder,Ocarina,Piccolo,Samba Whistle,Brass
  DATA Woodwind,Human Voice 1,Human Voice 2,Human Chorus,Kazoo,Saw,Sinewave
  DATA Bank 1,Bank 2,Bank 3,Bank 4,Bank 5
  '
  DATA ,,,,,,,,,,,,,,                           !need dummy strings
  '
  REPEAT
    '
    RESTORE voices2             !point to 1st DATA item
    '
    x1=10                       !1st column coordinates
    y1=15
    x2=125
    y2=28
    '
    FOR i=61 TO 72              !send voices from 1st column
      sendmidi
    NEXT i
    '
    x1=130                      !2nd column coordinates
    y1=15
    x2=245
    y2=28
    '
    FOR i=73 TO 84              !send voices from 2nd column
      sendmidi
    NEXT i
    '
    x1=250                      !3rd column coordinates
    y1=15
    x2=365
    y2=28
    '
    FOR i=85 TO 96              !send voices from 3rd column
      sendmidi
    NEXT i
    '
    x1=370                      !4th column coordinates
    y1=15
    x2=485
    y2=28
    '
    FOR i=97 TO 105             !send voices from 4th column
      sendmidi
    NEXT i
    '
    i=1                         !reset counter and preset #
    PAUSE 15                    !prevent mouse bounce
    EXIT IF presetno>presets    !don't continue selections if > preset #
    '
  UNTIL MOUSEK=2                !exit loop for right mouse button
  '
  RESTORE voices2               !point to 1st DATA item
  '
RETURN
'
PROCEDURE style1
  '
  mididata=2                    !initialize for styledata
  RESTORE styles1               !Point to DATA items
  DEFTEXT 2,1,0,6               !Text=red,bold,left-right,small script
  DEFFILL ,1                    !bitpattern=filled
  GRAPHMODE 2                   !transparent mode
  '
  x1=10                         !initialize rectangle coordinates
  y1=15
  x2=125
  y2=28
  FOR i=1 TO 5                  !create column display
    IF i>1 THEN
      x1=x1+120                 !set up next column
      x2=x2+120
      y1=15
      y2=28
    ENDIF
    FOR j=1 TO 12               !create row display
      READ midi$               !Get text
      createmidibutton         !Draw the rectangle
    NEXT j
  NEXT i
  '
  styles1:
  DATA Rhythm/Blues 1,Rhythm/Blues 2,Slow Blues,Gospel,Disco,Rap,Safari,Fusion 1
  DATA Fusion 2,16 Beat 1,16 Beat 2,Techno Rock 1,Techno Rock 2,Funk 1,Funk 2
  DATA Funk 3,Funk 4,Rock N Roll 1,Rock N Roll 2,Rock N Roll 3,Rock Ballad
  DATA Hard Rock,Heavy Metal,Speed Metal,Pop Rock 1,Pop Rock 2,Rock Baroque
  DATA Christmas Rock,Oriental Rock,Brass Rock,Swing Guitar,Swing Piano
  DATA Swing Organ,Swing Vibes,Big Band 1,Big Band 2,Big Band 3,Big Band Waltz
  DATA Modern Jazz,Jazz Waltz,5/4 Swing,Jazz Ballad,Shuffle,Boogie 1,Boogie 2
  DATA Boogie 3,Boogie 4,Boogie 5,Dixie Combo,Dixie Banjo,Jazz Baroque
  DATA Bossa Nova 1,Bossa Nova 2,Samba 1,Samba 2,Samba 3,Salsa 1,Salsa 2
  DATA Salsa 3,Tango
  '
  REPEAT
    RESTORE styles1             !point to first DATA item
    '
    x1=10                       !1st column coordinates
    y1=15
    x2=125
    y2=28
    '
    FOR i=1 TO 12               !send styles from 1st column
      sendmidi
    NEXT i
    '
    x1=130                      !2nd column coordinates
    y1=15
    x2=245
    y2=28
    '
    FOR i=13 TO 24              !send styles from 2nd column
      sendmidi
    NEXT i
    '
    x1=250                      !3rd column coordinates
    y1=15
    x2=365
    y2=28
    '
    FOR i=25 TO 36              !send styles from 3rd column
      sendmidi
    NEXT i
    '
    x1=370                      !4th column coordinates
    y1=15
    x2=485
    y2=28
    '
    FOR i=37 TO 48              !send styles from 4th column
      sendmidi
    NEXT i
    '
    x1=490                      !5th column coordinates
    y1=15
    x2=605
    y2=28
    '
    FOR i=49 TO 60              !send styles from 5th column
      sendmidi
    NEXT i
    '
    i=1                         !reset counter and preset #
    PAUSE 15                    !prevent mouse bounce
    EXIT IF presetno>presets    !don't continue selections if > preset #
    '
  UNTIL MOUSEK=2                !exit for right mouse button
  '
  RESTORE styles1               !point to 1st DATA item
  '
RETURN
'
PROCEDURE style2
  '
  mididata=2                    !initialize for styledata
  RESTORE styles2               !Point to DATA items
  DEFTEXT 2,1,0,6               !Text=red,bold,left-right,small script
  DEFFILL ,1                    !bitpattern=filled
  GRAPHMODE 2                   !transparent mode
  '
  x1=10                         !initialize rectangle coordinates
  y1=15
  x2=125
  y2=28
  FOR i=1 TO 5                  !create column display
    IF i>1 THEN
      x1=x1+120                 !set up next column
      x2=x2+120
      y1=15
      y2=28
    ENDIF
    FOR j=1 TO 12               !create row display
      READ midi$                !Get text
      createmidibutton          !Draw the rectangle
    NEXT j
  NEXT i
  '
  styles2:
  DATA Habanera,Mambo 1,Mambo 2,Mambo 3,Rhumba,Cha-Cha-Cha,Conga,Merengue
  DATA Calypso 1,Calypso 2,Son Afro,Reggae,Cuban,Beguine,Island Folk
  DATA Mariachi,Argentine,March 1,March 2,Majestic March,Fanfare,Lullaby
  DATA Baroque,Baroqu Waltz,String Quartet,Viennese,Polka,Bolero,Flamenco
  DATA Class Guitar,Ragtime Piano,Country,Country Piano,Country Guitar
  DATA Bluegrass,Street Organ,Hawaiian,Mandolin,Chanson,Barbershop
  DATA ,,,,,,,,,,,,,,,,,,,
  REPEAT
    '
    RESTORE styles2             !point to 1st DATA item
    '
    x1=10                       !1st column coordinates
    y1=15
    x2=125
    y2=28
    '
    FOR i=61 TO 72              !send styles from 1st column
      sendmidi
    NEXT i
    '
    x1=130                      !2nd column coordinates
    y1=15
    x2=245
    y2=28
    '
    FOR i=73 TO 84              !send styles from 2nd column
      sendmidi
    NEXT i
    '
    x1=250                      !3rd column coordinates
    y1=15
    x2=365
    y2=28
    '
    FOR i=85 TO 96              !send styles from 3rd column
      sendmidi
    NEXT i
    '
    x1=370                      !4th column coordinates
    y1=15
    x2=485
    y2=28
    '
    FOR i=97 TO 100             !send styles from 4th column
      sendmidi
    NEXT i
    '
    i=1                         !reset counter and preset #
    PAUSE 15                    !prevent mouse bounce
    EXIT IF presetno>presets    !don't continue selections if > preset #
    '
  UNTIL MOUSEK=2                !exit loop for right mouse button
  '
  RESTORE styles2               !point to 1st DATA item
  '
RETURN
'
PROCEDURE createmidibutton
  '
  PBOX x1,y1,x2,y2              !create each midi box for each row
  TEXT x1+1,y1+8,midi$          !place text inside box
  y1=y1+15                      !update the row position
  y2=y2+15
  '
RETURN
'
PROCEDURE sendmidi
  '
  READ midi$                    !read text
  a=MOUSEX                      !get mouse x coordinate
  b=MOUSEY                      !get mouse y coordinate
  IF a>x1 AND b>y1 AND a<x2 AND b<y2 THEN
    IF MOUSEK=1 THEN            !if left mouse button was pressed
      DEFFILL ,1
      DEFTEXT 3                 !change text color to green
      PBOX x1,y1,x2,y2          !redraw box
      TEXT x1+1,y1+8,midi$      !redraw text
      IF midimode=0 THEN
        IF mididata=1 THEN      !check voice/style flag
          OUT 3,voicechange,i-1 !output voice data thru MIDI port
        ELSE
          OUT 3,stylechange,i-1 !output style data thru MIDI port
        ENDIF
      ELSE IF midimode=1
        PRINT AT(60,1);"Preset = ";presetno+1;  !display count
        INC presetno                            !increment the preset count
        IF presetno>=presets THEN
          PRINT AT(60,1);"Done!               " !don't allow more selections
        ENDIF
        a$(n)=midi$             !store text
        IF mididata=1 THEN
          voice(n)=i-1          !store voice preset #
          presetflag(n)=mididata !store voice flag
          INC n                 !increment array subscript
        ELSE
          style(n)=i-1          !store style preset #
          presetflag(n)=mididata !store style flag
          INC n                 !increment array subscript
        ENDIF
      ENDIF
    ENDIF
  ENDIF
  y1=y1+15                      !update row position
  y2=y2+15
  '
RETURN
'
PROCEDURE playselect
  '
  CLS                           !Clear the screen
  x1=10                         !set up cursor positions
  x2=40
  y1=12
  y2=12
  PRINT AT(x1,10);"VOICES"
  PRINT AT(x2,10);"RHYTHMS"
  PRINT AT(50,24);"Press Start/Stop on Synth"
  '
  DO
    start=INP(3)                !get MIDI data from synth
  LOOP UNTIL start=&HFA         !wait for start/stop button on synth
  '
  DO
    n=0                         !initialize array subscript
    FOR p=1 TO presets
      IF presetflag(n)=1 THEN
        PRINT AT(x1,y1);a$(n)   !display voice text string
        INC y1                  !update voice row
        OUT 3,voicechange,voice(n) !send current voice preset # to synth
      ELSE IF presetflag(n)=2
        PRINT AT(x2,y2);a$(n)   !display style text string
        INC y2                  !update style row
        OUT 3,stylechange,style(n) !send current style preset # to synth
      ENDIF
      INC n                     !update array subscript
      FOR k=1 TO interval       !delay loop based on time interval
        stop=INP(3)             !check for start/stop button on synth
        EXIT IF stop=&HFC
      NEXT k
      EXIT IF stop=&HFC
    NEXT p
    EXIT IF stop=&HFC
  LOOP
  '
  CLS                           !clear the screen
  CLR midimode                  !clear all variables
  selecionbutton=1
  viewbutton=1
  MENU m$()                     !display main menu
  '
RETURN
'
PROCEDURE presetno
  '
  CLS
  MENU m$()
  CLR presets,presetno,n        !initialize all pertinent variables
  DEFTEXT 1,1,0,12,0
  message$="How Many Presets?"  !get # of presets
  TEXT 10,60,message$
  presets1$=INPUT$(1)           !get first character
  TEXT 150,60,presets1$         !echo back
  presets2$=INPUT$(1)           !get second character
  TEXT 160,60,presets2$         !echo back
  presets=VAL(presets1$+presets2$) !# of presets = 1st & 2nd combined
  IF presets<1 OR presets>99 THEN
    message$="Input Error!"
    TEXT 10,90,message$
    CLR n,midimode            !clear all variables
    CLR presets,presetno      !initialize all pertinent variables
    selecionbutton=1
    viewbutton=1
    GOTO donepresetno
  ENDIF
  timeint                       !get time interval in between presets
  '
  donepresetno:
RETURN
'
PROCEDURE summarize
  '
  CLS
  DEFTEXT 1,1,0,14               !Text=red,bold,left-right,small script
  selecion$="C u r r e n t   V o i c e   a n d   R h y t h m   P r e s e t s"
  TEXT 20,12,selecion$
  DEFFILL ,1                    !bitpattern=filled
  GRAPHMODE 2                   !transparent mode
  '
  n=0                           !initialize array subscript
  x1=10                         !initialize rectangle coordinates
  y1=15
  x2=125
  y2=28
  FOR i=1 TO 5                  !create column display
    IF i>1 THEN
      x1=x1+120                 !set up next column
      x2=x2+120
      y1=15
      y2=28
    ENDIF
    FOR j=1 TO 12               !create row display
      midi$=a$(n)               !Get text
      IF presetflag(n)=1 THEN
        DEFTEXT 2,1,0,6         !use red for voice selections
      ELSE
        DEFTEXT 3,1,0,6         !use green for style selections
      ENDIF
      createmidibutton          !Draw the rectangle
      INC n                     !update to next text array
    NEXT j
  NEXT i
  '
  DO
  LOOP UNTIL MOUSEK=2           !wait for right mouse key
  '
  CLS                           !Clear screen
  MENU m$()                     !display main menu
RETURN
'
'
PROCEDURE timeint               !created via GFA Companion
  '
  lx=190
  rx=450
  ty=15
  by=150
  SGET tempuse$
  GRAPHMODE 1
  DEFFILL 1,2,2
  DEFTEXT 1,0,0,6
  DEFLINE 1,3
  @timeint.lstgrowbox(lx,ty,10,10,lx,ty,rx-lx,by-ty)
  PBOX lx,ty,rx,by
  BOX lx,ty,rx,by
  DEFLINE 1,1
  TEXT lx+30,ty+10,"  Preset Time Interval  "
  DEFFILL 1,2,8
  PBOX lx+25,ty+25,rx-200,ty+40
  PBOX lx+25,ty+45,rx-200,ty+60
  PBOX lx+25,ty+65,rx-200,by-55
  PBOX lx+25,by-50,rx-200,by-35
  DEFFILL 0,2,8
  PBOX lx+25,ty+25,rx-203,ty+39
  PBOX lx+25,ty+45,rx-203,ty+59
  PBOX lx+25,ty+65,rx-203,by-56
  PBOX lx+25,by-50,rx-203,by-36
  BOX lx+25,ty+25,rx-203,ty+39
  BOX lx+27,ty+27,rx-205,ty+37
  BOX lx+25,ty+45,rx-203,ty+59
  BOX lx+27,ty+47,rx-205,ty+57
  BOX lx+25,ty+65,rx-203,by-56
  BOX lx+27,ty+67,rx-205,ty+77
  BOX lx+25,by-50,rx-203,by-36
  BOX lx+27,by-48,rx-205,by-38
  TEXT lx+38,ty+35,"1"
  TEXT lx+38,ty+55,"2"
  TEXT lx+38,by-60,"3"
  TEXT lx+38,by-40,"4"
  TEXT lx+68,ty+35,"       fastest       "
  TEXT lx+68,ty+55,"       less fast     "
  TEXT lx+68,by-60,"       more slower   "
  TEXT lx+68,by-40,"       slowest       "
  ' Now to get answers for you
  CLR choice1,choice2,choice3,choice4
  interval=0
  REPEAT
    x=MOUSEX
    y=MOUSEY
    k=MOUSEK
    IF x>lx+27 AND x<rx-205 AND y>ty+27 AND y<ty+37 AND k=1
      interval=750
      IF choice1=1
        DEFTEXT 1
        GRAPHMODE 1
        DEFLINE 1,1
        DEFFILL 1,2,8
        PBOX lx+25,ty+25,rx-200,ty+40
        DEFFILL 0,2,8
        PBOX lx+25,ty+25,rx-203,ty+39
        BOX lx+25,ty+25,rx-203,ty+39
        BOX lx+27,ty+27,rx-205,ty+37
        TEXT lx+38,ty+35,"1"
        choice1=0
      ELSE
        GRAPHMODE 2
        choice1=1
        DEFFILL 0,2,8
        PBOX lx+25,ty+25,rx-200,ty+40
        DEFFILL 1,2,8
        PBOX lx+25,ty+25,rx-203,ty+39
        DEFLINE 0,1
        GRAPHMODE 3
        BOX lx+27,ty+27,rx-205,ty+37
        DEFTEXT 0
        TEXT lx+38,ty+35,"1"
      ENDIF
    ENDIF
    IF x>lx+27 AND x<rx-205 AND y>ty+47 AND y<ty+57 AND k=1
      interval=1500
      IF choice2=1
        DEFTEXT 1
        GRAPHMODE 1
        DEFLINE 1,1
        DEFFILL 1,2,8
        PBOX lx+25,ty+45,rx-200,ty+60
        DEFFILL 0,2,8
        PBOX lx+25,ty+45,rx-203,ty+59
        BOX lx+25,ty+45,rx-203,ty+59
        BOX lx+27,ty+47,rx-205,ty+57
        TEXT lx+38,ty+55,"2"
        choice2=0
      ELSE
        GRAPHMODE 2
        choice2=1
        DEFFILL 0,2,8
        PBOX lx+25,ty+45,rx-200,ty+60
        DEFFILL 1,2,8
        PBOX lx+25,ty+45,rx-203,ty+59
        DEFLINE 0,1
        GRAPHMODE 3
        BOX lx+27,ty+47,rx-205,ty+57
        DEFTEXT 0
        TEXT lx+38,ty+55,"2"
      ENDIF
    ENDIF
    IF x>lx+27 AND x<rx-205 AND y>ty+67 AND y<ty+77 AND k=1
      interval=3000
      IF choice3=1
        DEFTEXT 1
        GRAPHMODE 1
        DEFLINE 1,1
        DEFFILL 1,2,8
        PBOX lx+25,ty+65,rx-200,by-55
        DEFFILL 0,2,8
        PBOX lx+25,ty+65,rx-203,by-56
        BOX lx+25,ty+65,rx-203,by-56
        BOX lx+27,ty+67,rx-205,ty+77
        TEXT lx+38,by-60,"3"
        choice3=0
      ELSE
        GRAPHMODE 2
        choice3=1
        DEFFILL 0,2,8
        PBOX lx+25,ty+65,rx-200,by-55
        DEFFILL 1,2,8
        PBOX lx+25,ty+65,rx-203,by-56
        DEFLINE 0,1
        GRAPHMODE 3
        BOX lx+27,ty+67,rx-205,ty+77
        DEFTEXT 0
        TEXT lx+38,by-60,"3"
      ENDIF
    ENDIF
    IF x>lx+27 AND x<rx-203 AND y>by-48 AND y<by-28 AND k=1
      interval=4500
      IF choice4=1
        DEFTEXT 1
        GRAPHMODE 1
        DEFLINE 1,1
        DEFFILL 1,2,8
        PBOX lx+25,by-50,rx-200,by-35
        DEFFILL 0,2,8
        PBOX lx+25,by-50,rx-203,by-36
        BOX lx+25,by-50,rx-203,by-36
        BOX lx+27,by-48,rx-205,by-38
        TEXT lx+38,by-40,"4"
        choice4=0
      ELSE
        GRAPHMODE 2
        choice4=1
        DEFFILL 0,2,8
        PBOX lx+25,by-50,rx-200,by-35
        DEFFILL 1,2,8
        PBOX lx+25,by-50,rx-203,by-36
        DEFLINE 0,1
        GRAPHMODE 3
        BOX lx+27,by-48,rx-205,by-38
        DEFTEXT 0
        TEXT lx+38,by-40,"4"
      ENDIF
    ENDIF
  UNTIL interval<>0
  PAUSE 5
  GRAPHMODE 1
  DEFLINE 1
  DEFTEXT 1
  SPUT tempuse$
  @timeint.lstshrinkbox(lx,ty,20,5,lx,ty,rx-lx,by-ty)
  CLR tempuse$
  CLS
  MENU m$()
  '
RETURN
'
' These are the GEM¿ GRAF_GROWBOX & GRAF_SHRINKBOX Routines
' Init stands for Initial(X,Y,Height) and Fin stands for Final(X,Y,Height)
PROCEDURE timeint.lstgrowbox(init_x%,init_y%,init_w%,init_h%,fin_x%,fin_y%,fin_w%,fin_h%)
  '
  DPOKE GINTIN,init_x%
  DPOKE GINTIN+2,init_y%
  DPOKE GINTIN+4,init_w%
  DPOKE GINTIN+6,init_h%
  DPOKE GINTIN+8,fin_x%
  DPOKE GINTIN+10,fin_y%
  DPOKE GINTIN+12,fin_w%
  DPOKE GINTIN+14,fin_h%
  GEMSYS 73
  '
RETURN
PROCEDURE timeint.lstshrinkbox(fin_x%,fin_y%,fin_w%,fin_h%,init_x%,init_y%,init_w%,init_h%)
  '
  DPOKE GINTIN,fin_x%
  DPOKE GINTIN+2,fin_y%
  DPOKE GINTIN+4,fin_w%
  DPOKE GINTIN+6,fin_h%
  DPOKE GINTIN+8,init_x%
  DPOKE GINTIN+10,init_y%
  DPOKE GINTIN+12,init_w%
  DPOKE GINTIN+14,init_h%
  GEMSYS 74
  '
RETURN
REM ###################### end  TIMEINT.LST  procedure ####################
'
PROCEDURE helpmenus
  CLS
  LOCATE 20,1
  PRINT "YAMAHA PSS-480 VOICE AND STYLE CHANGER."
  PRINT
  PRINT "Welcome to the Yamaha PSS-480 voice and style changer.  This program"
  PRINT "allows you to change a voice or style (rhythm) via the mouse.  This "
  PRINT "is a plus since all the voices and styles are kind of small on the "
  PRINT "synthesizer itself; you can see the selections alot clearer on the"
  PRINT "computer screen.  There are 4 menus that are set up in a 12 X 5 matrix"
  PRINT "where menus 1 & 2 are for the voices and menus 3 & 4 are for the "
  PRINT "styles.  Since there are at least 100 presets for each, they are "
  PRINT "broken up into 2 menus apiece.  Basically, you use the right mouse"
  PRINT "button to bring up the pull-down menus and select one of the 4 menus."
  PRINT "and when the screen fills up with a menu, you use the left mouse "
  PRINT "button to select the voice or style....It's that simple!  The display"
  PRINT "on the Yamaha should indicate which preset no was selected (Note:"
  PRINT "the MIDI mode should be on Keyboard Assign Mode[00] thoughout the"
  PRINT "use of this program!).  The color of the voice or style should "
  PRINT "change when it is selected.  The color scheme of the entire program "
  PRINT "works best with the system default colors."
  PRINT
  PRINT "DA's work fine with this program.  I recommend QuickST or Turbo ST"
  PRINT "which will fill the screen up faster than normal since GFA Graphics"
  PRINT "commands are used to create the boxes and text."
  PRINT
  PRINT "Click right mouse button to return to the main menu."
  DO UNTIL MOUSEK=2
  LOOP
  CLS
  MENU m$()
RETURN
'
PROCEDURE helpexecute
  CLS
  LOCATE 20,1
  PRINT "AUTOMATING SELECTIONS"
  PRINT
  PRINT "This program also allows you to select up to 99 voices and styles"
  PRINT "(presets) to be automatically sent to the Yamaha when playing it"
  PRINT "real-time.  The following is a description of all dropdown items:"
  PRINT
  PRINT "Make Selections: enter the total # of presets, followed by a time"
  PRINT "interval between each selection.  Then use the Voice or Style Menus"
  PRINT "and make all your selections.  You can call up as many menus as you"
  PRINT "want."
  PRINT
  PRINT "View Selections: lists all selections where red indicates voice,green"
  PRINT "indicates style.  This is also the order in which the selections will"
  PRINT "be sent."
  PRINT
  PRINT "Play Tune: Press Start/Stop on Yamaha.  The display will list all"
  PRINT "selections as they are sent to the synth.  The delay between selections"
  PRINT "is based on the time interval.  The program will cycle through all"
  PRINT "selections and then continuously loop.  Press Start/Stop again to return"
  PRINT "control back to the ST."
  PRINT
  PRINT "Quit Yamaha PSS-480: Quit program and return to desktop."
  PRINT
  PRINT "Click Right mouse button to return to the main menu."
  DO UNTIL MOUSEK=2
  LOOP
  CLS
  MENU m$()
RETURN
