November 23, 2024, 09:32:19 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Return of the Mourner...

Started by LPFreak1283, October 03, 2009, 04:10:51 PM

Previous topic - Next topic

LPFreak1283

Hey Jon....long time no talk!  lol.  I have dusted off my mourner prop for tweaking for the 2009 Halloween season...

One major thing I wanna change is the fact that the scare never seemed to work because the timing was off....my solution (prolly nuts) is to use the pressure mat as the trigger to scare...

I have a handheld switch i wanna use to turn the prop on....so she would cry all the time...until you stepped on the mat then she would scream instantly...and when she was done she would continue to cry...

The handheld would be like an on off switch...and the may switch will just trigger the scare...

Any help??  :)

Here's the original code:

' =========================================================================
'
'   File....... Mourner.BS2
'   Purpose.... Halloween 2008 Project
'   Author..... FrontYardHaunters.com
'   E-mail..... SabresNut42383@roadrunner.com
'   Started.... April 6, 2008
'   Updated.... 22 MAY 2008 - Jon Williams
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------
'
' 1.00   - Original program
' 1.01   - Jon Williams updated for state-driven operation
' 2.00   - My update removing AP-8 and adding VMusic2
' 2.01   - back to linear with subs for delays and servo processing


' -----[ I/O Definitions ]-------------------------------------------------

Sio             PIN     15                      ' Remove Setup; no ULN
TX              PIN     14                      ' SETUP = UP; no ULN
MatSwitch       PIN     13                      ' SETUP = DN; no ULN
HandHeld        PIN     12                      ' SETUP = DN; no ULN
Servo           PIN     8


' -----[ Constants ]-------------------------------------------------------

T9600           CON     84
T38K4           CON     6
Open            CON     $8000
OT38K4          CON     Open + T38K4            ' B/R in RC4
OT9600          CON     Open + T9600            ' VM2 baud rate

IsOn            CON     1
IsOff           CON     0

AllOff          CON     %0000
Spot            CON     %0001                   ' K1 relay on
Weep            CON     %0010                   ' K2 relay on
SpotWeep        CON     %0011                   ' K1 % K2 realys on
StrobeFog       CON     %1100                   ' K3 & K4 relays on


' -----[ Variables ]-------------------------------------------------------

pos             VAR     Word                    ' servo position
timer           VAR     Word                    ' for delays

skipScare       VAR     Bit                     ' don't use Scare section


' -----[ EEPROM Data ]-----------------------------------------------------


' -----[ Initialization ]--------------------------------------------------

Reset:
  LOW Servo
  pos = 750
  timer = 2500
  GOSUB Servo_Pause

  skipScare = IsOff

  SEROUT TX, OT9600, ["VST", CR]                ' stop VMUSIC player
  GOSUB RC4_Reset                               ' clear RC-4


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 100                                   ' preload debounce time
  DO WHILE timer > 0
    GOSUB Refresh_Servo
    IF (MatSwitch = IsOff) THEN                 ' if no input
      timer = 100                               ' reload debounce timer
    ENDIF
  LOOP


Cry:
  GOSUB Refresh_Servo
  SEROUT Sio, OT38K4, ["!RC4", %00, "S", Weep]
  GOSUB Refresh_Servo
  SEROUT  TX, OT9600, ["VRF weep.mp3", CR]
  timer = 20000
  GOSUB Servo_Pause


Suspense:
  SEROUT TX, OT9600, ["VP", CR]                 ' pause weeping
  SEROUT Sio, OT38K4, ["!RC4", %00, "S", AllOff]

  ' turn head slowly to left

  FOR pos = 750 TO 500 ' STEP 2
    GOSUB Refresh_Servo
  NEXT

  timer = 3500
  GOSUB Servo_Pause

  ' turn head back to center

  FOR pos = 500 TO 750 ' STEP 2
    GOSUB Refresh_Servo
  NEXT

  IF (skipScare = IsOn) THEN Finish


Choose:
  IF (HandHeld = IsOn) THEN
    GOTO Scare
  ELSE
    skipScare = IsOn
    GOTO Cry
  ENDIF


Scare:
  GOSUB Refresh_Servo
  SEROUT Sio, OT38K4, ["!RC4", %00, "S", StrobeFog]
  GOSUB Refresh_Servo
  SEROUT TX, OT9600, ["VPF scream.mp3", CR]
  pos = 250
  timer = 5000
  GOSUB Servo_Pause


Finish:
  SEROUT TX, OT9600, ["VRF weep.mp3", CR]
  GOSUB Refresh_Servo
  SEROUT Sio, OT38K4, ["!RC4", %00, "S", SpotWeep]
  timer = 30000
  GOSUB Servo_Pause
  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

RC4_Reset:
  SEROUT Sio, OT38K4, ["!!!!!!!RC4", %00, "S", Spot]

' -------------------------------------------------------------------------

' Use as a replacement for PAUSE
' -- keeps servo in desired position
' -- load "timer" with desired delay

Servo_Pause:
  DO WHILE timer > 19
    GOSUB Refresh_Servo
  LOOP
  RETURN

' -------------------------------------------------------------------------

' Updates servo and decrents timer for time used

Refresh_Servo:
  PULSOUT Servo, pos
  PAUSE 18
  timer = timer - 20
  RETURN

JonnyMac

Do you need my help? -- or are you asking if I think you need my help?  I don't think you do.

In care you're just knocking the rust of I suggest you put the "weeping" audio into repeat mode until you get the trigger.  Then, move the servo and call the scream track.  Pretty easy, really.  Give it a shot and I'll bail you out if needed.  ;D
Jon McPhalen
EFX-TEK Hollywood Office

LPFreak1283

I have trust in myself to figure these things out.  Im glad you help to solidify it!  I did write what I wanted to do so many months ago...and I lost it...that was bad.  So here is what I came up with...I havent tested it since I am not near my prop  :-\

' =========================================================================
'
'   File....... Mourner.BS2
'   Purpose.... Halloween 2008 Project
'   Author..... FrontYardHaunters.com
'   E-mail..... SabresNut42383@roadrunner.com
'   Started.... April 6, 2008
'   Updated.... 5 October 2009 - Cory Baumgart
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------
'
' 1.00   - Original program
' 1.01   - Jon Williams updated for state-driven operation
' 2.00   - My update removing AP-8 and adding VMusic2
' 2.01   - back to linear with subs for delays and servo processing
' 3.00   - Overhaul to original.  Remove all time restraints


' -----[ I/O Definitions ]-------------------------------------------------

Sio             PIN     15                      ' Remove Setup; no ULN
TX              PIN     14                      ' SETUP = UP; no ULN
MatSwitch       PIN     13                      ' SETUP = DN; no ULN
HandHeld        PIN     12                      ' SETUP = DN; no ULN
Servo           PIN     8


' -----[ Constants ]-------------------------------------------------------

T9600           CON     84
T38K4           CON     6
Open            CON     $8000
OT38K4          CON     Open + T38K4            ' B/R in RC4
OT9600          CON     Open + T9600            ' VM2 baud rate

IsOn            CON     1
IsOff           CON     0

Spot            CON     %0001                   ' K1 relay on
StrobeFog       CON     %1100                   ' K3 & K4 relays on


' -----[ Variables ]-------------------------------------------------------

pos             VAR     Word                    ' servo position
timer           VAR     Word                    ' for delays

' -----[ EEPROM Data ]-----------------------------------------------------


' -----[ Initialization ]--------------------------------------------------

Reset:
  LOW Servo
  pos = 750
  timer = 2500
  GOSUB Servo_Pause

  SEROUT TX, OT9600, ["VST", CR]                ' stop VMUSIC player
  GOSUB RC4_Reset                               ' clear RC-4


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 100                                   ' preload debounce time
  DO WHILE timer > 0
    GOSUB Refresh_Servo
    IF (HandHeld = IsOff) THEN                 ' if no input
      timer = 100                               ' reload debounce timer
    ENDIF
  LOOP


Cry:
  GOSUB Refresh_Servo
  SEROUT Sio, OT38K4, ["!RC4", %00, "S", Spot]
  SEROUT  TX, OT9600, ["VRF weep.mp3", CR]
    timer = 100
      DO WHILE timer > 0
        GOSUB ReFresh_Servo
        IF (MatSwitch = IsOff) THEN
          timer = 100
        ENDif
      loop


Scare:
  GOSUB Refresh_Servo
  SEROUT Sio, OT38K4, ["!RC4", %00, "S", StrobeFog]
  GOSUB Refresh_Servo
  SEROUT TX, OT9600, ["VPF scream.mp3", CR]
  pos = 250
  timer = 5000
  GOSUB Servo_Pause
  pos = 750
  GOTO Main

' -----[ Subroutines ]-----------------------------------------------------

RC4_Reset:
  SEROUT Sio, OT38K4, ["!!!!!!!RC4", %00, "S", Spot]

' -------------------------------------------------------------------------

' Use as a replacement for PAUSE
' -- keeps servo in desired position
' -- load "timer" with desired delay

Servo_Pause:
  DO WHILE timer > 19
    GOSUB Refresh_Servo
  LOOP
  RETURN

' -------------------------------------------------------------------------

' Updates servo and decrents timer for time used

Refresh_Servo:
  PULSOUT Servo, pos
  PAUSE 18
  timer = timer - 20
  RETURN

JonnyMac

Do me a favor and spell out what you want -- in *gory* detail -- so that I can compare what you want (in English) versus what you've coded in PBASIC; that will help me help you with better direction.  Please keep in mind that while I have a vague memory of your prop, I've written more than 1000 programs since then and the details of your device are lost on me.
Jon McPhalen
EFX-TEK Hollywood Office

LPFreak1283

Hey Jon, Sorry for the long delay in response!  Work sucks all the life outta me!! lol. 

My setup is as follows:
Pin 15 - RC-4
Pin 14 - VMusic
Pin 13 - Mat Switch
Pin 12 - Hand Held
Pin 8 - Servo
On the RC-4, Relay one is a red spot light that is always on when relays 3&4 arent.  Those relays are a strobe light and fog machine that turn on when she is triggered to scare.

What I would like to happen is this:
1) The handheld will literally be an on/off switch for the program to run.  When its on, the program will loop the crying continuously.  In my previous code, the matswitch started the program.

2) I would like the matswitch to make her scare as soon as I press it (or even a few secs afterwards would work too).  In my old code, I had timers that I relied on to do the scare and they just were too long.  A simple fix would be to shorten the timers. 

So basically I am looking for the program to initialize with only the spot light on and looking for the handheld to be triggered.

Then when the handheld is triggered, the program loops the crying

While it is doing that, the program is waiting for the matswitch to be triggered to do the actual scare, which involves the servo being moved, and relays 3&4 to turn on while relay one shuts off.  After about a ten second scare, the program goes all the way back to the beginning.

JonnyMac

October 26, 2009, 11:33:16 AM #5 Last Edit: October 26, 2009, 06:07:50 PM by JonnyMac
Here you go.  Note that I modified some of your IOs to conform with my VMUSIC template and routines.  I also employed a trick using an unused pin for another PULSOUT to create a high-resolution delay in the Servo_Pause subroutine.  PULSOUT has 500x the resolution of PAUSE so it makes sense to do this, especially when you call Servo_Pause with big values in timer.

' =========================================================================
'
'   File....... Mourner_2009.BS2
'   Purpose.... Halloween 2008 Project
'   Author..... FrontYardHaunters.com
'   E-mail..... SabresNut42383@roadrunner.com
'   Started.... April 6, 2008
'   Updated.... 26 OCT 2009 (JW)
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------
'
' 1.00   - Original program
' 1.01   - Jon Williams updated for state-driven operation
' 2.00   - My update removing AP-8 and adding VMusic2
' 2.01   - back to linear with subs for delays and servo processing
' 3.00   - Overhaul to original.  Remove all time restraints


' -----[ I/O Definitions ]-------------------------------------------------

RX              PIN     15                      ' no ULN / SETUP = UP
TX              PIN     14                      ' no ULN / SETUP = UP
Sio             PIN     13                      ' no ULN / SETUP = UP
MatSwitch       PIN     12                      ' SETUP = DN
HandCtrl        PIN     11                      ' ULN is pull-down

Servo           PIN      8

Pad             PIN      7                      ' use for h/r delay


' -----[ Constants ]-------------------------------------------------------

T2400           CON     396
T9600           CON     84
T19K2           CON     32
T38K4           CON     6

Open            CON     $8000

EfxBaud         CON     Open | T38K4
VmBaud          CON     Open | T2400

IsOn            CON     1
IsOff           CON     0

Spot            CON     %0001                   ' K1 relay on
StrobeFog       CON     %1100                   ' K3 & K4 relays on


' -----[ Variables ]-------------------------------------------------------

pos             VAR     Word                    ' servo position
timer           VAR     Word                    ' for delays
lottery         VAR     Word                    ' random #

idx             VAR     Byte                    ' loop control

relays          VAR     Byte
rSpot          VAR      relays.BIT0
rK2            VAR      relays.BIT1
rStrobe        VAR      relays.BIT2
rFog           VAR      relays.BIT3

triggers        VAR     Byte                    ' debounced inputs
trMat          VAR      triggers.Bit4
trHand         VAR      triggers.Bit3

mp3             VAR     Byte
eePntr          VAR     Byte
char            VAR     Byte


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  LOW Servo                                     ' make it an output
  pos = 750
  timer = 2500
  GOSUB Servo_Pause

Reset:
  GOSUB VM_Stop
  relays = Spot
  GOSUB RC4_Set


' -----[ Program Code ]----------------------------------------------------

Main:
  pos = 750
  timer = 0

  GOTO Test

Wait_Enable:
  GOSUB Refresh_Servo
  RANDOM lottery                                ' stir random #
  timer = (timer + 20) * HandCtrl               ' scan hand switch
  IF timer < 100 THEN Wait_Enable               ' wait for valid signal

Test:

  mp3 = 0                                       ' weeping track
  GOSUB VM_Repeat                               ' repeat it

Scan_Mat:
  triggers = %00011000                          ' arm triggers
  FOR idx = 1 TO 5                              ' 5 x 20ms = 100ms
    GOSUB Refresh_Servo
    RANDOM lottery                              ' stir random #
    triggers = triggers & INL                   ' scan inputs
  NEXT

  'IF trHand = IsOff THEN Reset                  ' pgm disabled
  IF trMat = IsOff THEN Scan_Mat                ' no "victim" yet

Scare_Delay:
  timer = lottery // 2001                       ' 0 to 2 seconds
  GOSUB Servo_Pause

Scare:
  GOSUB VM_Stop
  relays = StrobeFog
  GOSUB RC4_Set
  GOSUB Refresh_Servo

  mp3 = 1
  GOSUB VM_Play

  pos = 250                                     ' turn head
  timer = 10000                                 ' adjust for audio
  GOSUB Servo_Pause

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

RC4_Set:
  SEROUT Sio, EfxBaud, ["!RC4", %00, "S", relays]
  RETURN

' -------------------------------------------------------------------------

' Use as a replacement for PAUSE
' -- keeps servo in desired position
' -- load "timer" with desired delay

Servo_Pause:
  DO WHILE timer > 19
    GOSUB Refresh_Servo
  LOOP
  RETURN

' -------------------------------------------------------------------------

' Updates servo and decrents timer for time used

Refresh_Servo:
  PULSOUT Servo, pos
  PULSOUT Pad, (10000 - pos)                    ' hi-res delay
  INPUT Pad
  ' PAUSE 18
  timer = timer - 20
  RETURN

' -------------------------------------------------------------------------

VM_Stop:
  SEROUT TX, VmBaud, ["VST", CR]
  RETURN

' -------------------------------------------------------------------------

VM_Wait_Prompt:
  SERIN RX, VmBaud, [WAIT(">")]
  RETURN

' -------------------------------------------------------------------------

' Pass file # (index in DATA table) to play in "mp3"

VM_Play:
  SEROUT TX, VmBaud, ["VPF "]
  GOTO Play_MP3

' -------------------------------------------------------------------------

' Pass file # (index in DATA table) to play in "mp3"

VM_Repeat:
SEROUT TX, VmBaud, ["VRF "]
  GOTO Play_MP3

' -------------------------------------------------------------------------

' Pass file # (index in DATA table) to play in "mp3"

Play_MP3:
  eePntr = (8 * mp3) + Song_List

Send_Name:                                      ' send file title
  FOR idx = 1 TO 8                              ' max is 8 characters
    READ eePntr, char                           ' get a character
    IF char = 0 THEN Finish_Cmd                 ' if 0, we're at end
    SEROUT TX, VmBaud, [char]
    eePntr = eePntr + 1
  NEXT

Finish_Cmd:
  SEROUT TX, VmBaud, [".MP3", CR]               ' send extention + CR
  RETURN

' -------------------------------------------------------------------------

VM_Wait_Start:
  SERIN RX, VmBaud, [WAIT("T $")]
  RETURN

' -----[ User Data ]-------------------------------------------------------

' File names are stored on 8-byte boundaries -- this is very important for
' correct program operation.  This strategy uses a little more EE space but
' is easier to update and maintain

Song_List       DATA    @$00, "weep"             ' mp3 = 0
                DATA    @$08, "cry"              ' mp3 = 1
                DATA    @$10, "file3"
                DATA    @$18, "file4"
                DATA    @$20, "file5"
                DATA    @$28, "file5"
                DATA    @$30, "file6"
                DATA    @$38, "file7"
Jon McPhalen
EFX-TEK Hollywood Office

LPFreak1283

Wow....um....wow....Thanks Jon....

Ill have to hook this up asap and see it in action....

I love EFX-TEK....and the customer support....

LPFreak1283

Ok...well i hooked everything up...moved all my stuff around for the pin assignments...adjusted the setup jumpers....and loaded the program.

Turned on the prop-2....vmusic turned on...initialized...spot light came on...

Pressed the hand trigger and......

nothing...

The program never started.  I switched the hand and mat triggers on the prop-2....and that did nothing as well....

The only thing I don't have that you may is the RX side of the vmusic.  I never made a cable for it since I didnt think I needed it.  The program has it in there but its never called (as far as I can tell).  Should I make the connection and then try again??

JonnyMac

October 26, 2009, 06:01:48 PM #8 Last Edit: October 26, 2009, 06:06:49 PM by JonnyMac
Oops... I was using a trainer as my input hence had the trigger input set to INL (P6), this needs to change to INH adjustment of bits in the variable triggers (fixed).  I actually ran the program for quite a while using the Angel (TV show) theme song for the weeping and a lift of Captain Spalding (from House of 1000 Corpses) as the scream.
Jon McPhalen
EFX-TEK Hollywood Office

LPFreak1283

October 26, 2009, 06:29:55 PM #9 Last Edit: October 26, 2009, 06:36:31 PM by LPFreak1283
Jon, I for some reason had everything working but the sound....well my baud rate was wrong....so I changed it...

Well the weeping worked.....but when I triggered the scream, nothing happened....

Im dumb and never looked at the file names at the end of the file.  So I changed it and it works!!!!  I just tweaked the scream time a little....

The handheld seems to get skipped over in terms of starting and stopping the program tho...
**Edit**Nevermind....it works...

Here is my file so far:
' =========================================================================
'
'   File....... Mourner_2009.BS2
'   Purpose.... Halloween 2008 Project
'   Author..... FrontYardHaunters.com
'   E-mail..... SabresNut42383@roadrunner.com
'   Started.... April 6, 2008
'   Updated.... 26 OCT 2009 (JW)
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------
'
' 1.00   - Original program
' 1.01   - Jon Williams updated for state-driven operation
' 2.00   - My update removing AP-8 and adding VMusic2
' 2.01   - back to linear with subs for delays and servo processing
' 3.00   - Overhaul to original.  Remove all time restraints


' -----[ I/O Definitions ]-------------------------------------------------

RX              PIN     15                      ' no ULN / SETUP = UP
TX              PIN     14                      ' no ULN / SETUP = UP
Sio             PIN     13                      ' no ULN / SETUP = UP
MatSwitch       PIN     12                      ' SETUP = DN
HandCtrl        PIN     11                      ' ULN is pull-down

Servo           PIN      8

Pad             PIN      7                      ' use for h/r delay


' -----[ Constants ]-------------------------------------------------------

T2400           CON     396
T9600           CON     84
T19K2           CON     32
T38K4           CON     6

Open            CON     $8000

EfxBaud         CON     Open | T38K4
VmBaud          CON     Open | T9600

IsOn            CON     1
IsOff           CON     0

Spot            CON     %0010                   ' K1 relay on
StrobeFog       CON     %1100                   ' K3 & K4 relays on


' -----[ Variables ]-------------------------------------------------------

pos             VAR     Word                    ' servo position
timer           VAR     Word                    ' for delays
lottery         VAR     Word                    ' random #

idx             VAR     Byte                    ' loop control

relays          VAR     Byte
rSpot          VAR      relays.BIT0
rK2            VAR      relays.BIT1
rStrobe        VAR      relays.BIT2
rFog           VAR      relays.BIT3

triggers        VAR     Byte                    ' debounced inputs
trMat          VAR      triggers.BIT4
trHand         VAR      triggers.BIT3

mp3             VAR     Byte
eePntr          VAR     Byte
char            VAR     Byte


' -----[ Initialization ]--------------------------------------------------

Power_Up:
 LOW Servo                                     ' make it an output
 pos = 750
 timer = 2500
 GOSUB Servo_Pause

Reset:
 GOSUB VM_Stop
 relays = Spot
 GOSUB RC4_Set


' -----[ Program Code ]----------------------------------------------------

Main:
 pos = 750
 timer = 0

 GOTO Test

Wait_Enable:
 GOSUB Refresh_Servo
 RANDOM lottery                                ' stir random #
 timer = (timer + 20) * HandCtrl               ' scan hand switch
 IF timer < 100 THEN Wait_Enable               ' wait for valid signal

Test:

 mp3 = 0                                       ' weeping track
 GOSUB VM_Repeat                               ' repeat it

Scan_Mat:
 triggers = %00011000                          ' arm triggers
 FOR idx = 1 TO 5                              ' 5 x 20ms = 100ms
   GOSUB Refresh_Servo
   RANDOM lottery                              ' stir random #
   triggers = triggers & INH                   ' scan inputs
 NEXT

 IF trHand = IsOff THEN Reset                  ' pgm disabled
 IF trMat = IsOff THEN Scan_Mat                ' no "victim" yet

Scare_Delay:
 timer = lottery // 2001                       ' 0 to 2 seconds
 GOSUB Servo_Pause

Scare:
 GOSUB VM_Stop
 relays = StrobeFog
 GOSUB RC4_Set
 GOSUB Refresh_Servo

 mp3 = 1
 GOSUB VM_Play

 pos = 250                                     ' turn head
 timer = 5600                                 ' adjust for audio
 GOSUB Servo_Pause

 GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

RC4_Set:
 SEROUT Sio, EfxBaud, ["!RC4", %00, "S", relays]
 RETURN

' -------------------------------------------------------------------------

' Use as a replacement for PAUSE
' -- keeps servo in desired position
' -- load "timer" with desired delay

Servo_Pause:
 DO WHILE timer > 19
   GOSUB Refresh_Servo
 LOOP
 RETURN

' -------------------------------------------------------------------------

' Updates servo and decrents timer for time used

Refresh_Servo:
 PULSOUT Servo, pos
 PULSOUT Pad, (10000 - pos)                    ' hi-res delay
 INPUT Pad
 ' PAUSE 18
 timer = timer - 20
 RETURN

' -------------------------------------------------------------------------

VM_Stop:
 SEROUT TX, VmBaud, ["VST", CR]
 RETURN

' -------------------------------------------------------------------------

VM_Wait_Prompt:
 SERIN RX, VmBaud, [WAIT(">")]
 RETURN

' -------------------------------------------------------------------------

' Pass file # (index in DATA table) to play in "mp3"

VM_Play:
 SEROUT TX, VmBaud, ["VPF "]
 GOTO Play_MP3

' -------------------------------------------------------------------------

' Pass file # (index in DATA table) to play in "mp3"

VM_Repeat:
SEROUT TX, VmBaud, ["VRF "]
 GOTO Play_MP3

' -------------------------------------------------------------------------

' Pass file # (index in DATA table) to play in "mp3"

Play_MP3:
 eePntr = (8 * mp3) + Song_List

Send_Name:                                      ' send file title
 FOR idx = 1 TO 8                              ' max is 8 characters
   READ eePntr, char                           ' get a character
   IF char = 0 THEN Finish_Cmd                 ' if 0, we're at end
   SEROUT TX, VmBaud, [char]
   eePntr = eePntr + 1
 NEXT

Finish_Cmd:
 SEROUT TX, VmBaud, [".MP3", CR]               ' send extention + CR
 RETURN

' -------------------------------------------------------------------------

VM_Wait_Start:
 SERIN RX, VmBaud, [WAIT("T $")]
 RETURN

' -----[ User Data ]-------------------------------------------------------

' File names are stored on 8-byte boundaries -- this is very important for
' correct program operation.  This strategy uses a little more EE space but
' is easier to update and maintain

Song_List       DATA    @$00, "weep"             ' mp3 = 0
               DATA    @$08, "scream"              ' mp3 = 1
               DATA    @$10, "file3"
               DATA    @$18, "file4"
               DATA    @$20, "file5"
               DATA    @$28, "file5"
               DATA    @$30, "file6"
               DATA    @$38, "file7"