November 23, 2024, 03:37:23 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Chaser + randomizer LED program conversion from Prop 2 (not quite working)

Started by jukingeo, June 19, 2010, 02:40:04 PM

Previous topic - Next topic

jukingeo

Hello,

YES!  I am still around, but have been busy lately with a new job.  Remember when I mentioned doing game programs based on games I have seen at Chuck E. Cheese?  Well, my job JUST got easier in that realm because I now WORK for Chuck E. Cheese as a game technician.   YAY!!!!

Anyway, the program below was originally when I began learning on the BS2.  It was supposed to be a controller for a dashboard panel in a (now aborted) Back To The Future Delorean conversion project that never panned out.   At any rate, I thought the program would be useful for a game attract mode and I converted it from the Prop-2 to the Prop-1.

For some reason I had a much easier time converting from the Prop-1 to the Prop-2, but ran into several difficulties going the other way around.  This program was no different.

Now, on with the problem (I have set this up to use the Prop Trainer):

OK, what is supposed to happen is that 3 LEDs are to flash randomly while the remaining 3 LEDS are to chase.   The end result below has the random LEDS flashing too fast, but they do stay on their full length of time.   The chase LED's however, don't stay on for their duration, but just come on for a short blip and then extinguish.

I have a notion that my problem lies in the IF THEN command line as during the conversion this was originally set up as:

 

IF chaseTmr = 3 THEN                      

   READ pntr, tLeds                            
   LEDs = LEDs & %111000 | tLeds          
   pntr = pntr + 1 // 5                      
   chaseTmr = 0

ENDIF                      


I know that ENDIF's are a no no with the Prop-1.  So I made the alteration you see in the code below.  However, there is obviously something I missed.   Thus any assistance in rectifying the situation would be much appreciated.

Thank You,

Geo




' =========================================================================

'

'   File...... Chase_Plus_v2.BS2

'   Purpose...

'   Author.... Jon Williams, EFX-TEK

'   E-mail.... jwilliams@efx-tek.com

'   Started...

'   Updated...

'

'   {$STAMP BS1}

'   {$PBASIC 1.0}

'

' =========================================================================





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





' -----[ Revision History ]------------------------------------------------





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



SYMBOL          Speed    = 7                      ' SETUP = DN, no ULN

SYMBOL          Leds     = PINS





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



SYMBOL          IsOn   = 1

SYMBOL          IsOff  = 0





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



SYMBOL          chaseTmr  = B2                    ' cycles divider

SYMBOL          pntr      = B3                    ' pattern pointer

SYMBOL          tLeds     = B4                    ' holder for LEDs pattern

SYMBOL          idx       = B5                    ' loop controller

SYMBOL          lottery   = W3                    ' random value

SYMBOL          delay     = W4                    ' for timing





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



Reset:

 DIRS  = %00111111                             ' make LEDs outputs





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



Main:

 chaseTmr = chaseTmr + 1                       ' increment timer

 IF chaseTmr <> 3 THEN Timer                        ' time for new pattern



   READ pntr, tLeds                            ' yes, read pattern

   LEDs = LEDs & %111000 | tLeds               ' put on leds (protect others)

   pntr = pntr + 1 // 5                        ' update pattern pointer

   chaseTmr = 0                                ' reset timer





Timer:



 FOR idx = 1 TO 3

   RANDOM lottery                              ' stir random value

 NEXT



 LEDs = LEDs & %000111                         ' clear old random leds

 LEDS = LEDS | lottery & %111000               ' new random leds



Speed_Delay:

 POT Speed, 100, delay                         ' read raw delay

   delay = delay MIN 50                        ' set new range

   PAUSE delay                                 ' hold a bit

 GOTO Main





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





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



Chase:     EEPROM    (%000001)

               EEPROM    (%000011)

               EEPROM    (%000111)

               EEPROM    (%000110)

               EEPROM    (%000100)

               

JonnyMac

I'm late going out the door to meet friends (one is a very cute actress!) so I'll make this quick. 

The attached demo shows how to sequence the LEDs on P3..P5 while randomizing the LEDs on P0..P2.  Note that the order of expressions is critical with the Prop-1 because there is no operator precedence and no parenthesis to force the issue.

You should be able to take it from here.  Congrats on the new job!

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


' -----[ Revision History ]------------------------------------------------


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0


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

SYMBOL  timer           = B2
SYMBOL  idx             = B3
SYMBOL  leds            = B4


SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  idx = 0

Make_Leds:
  RANDOM lottery                                ' big stir, shake-up LSFR
  RANDOM lottery
  RANDOM lottery

  LOOKUP idx, (%001000, %010000, %100000), leds
  idx = idx + 1 // 3
  leds = lottery & %000111 | leds
  PINS = leds
  PAUSE 200
  IF Trigger = IsOn THEN Make_Leds
    PINS = %00000000
    GOTO Main


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


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


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




Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on June 19, 2010, 04:02:04 PM
I'm late going out the door to meet friends (one is a very cute actress!) so I'll make this quick.

It was no rush, but thank you for taking the quick time out!  Anyway, how did the evening go?

Quote
The attached demo shows how to sequence the LEDs on P3..P5 while randomizing the LEDs on P0..P2.  Note that the order of expressions is critical with the Prop-1 because there is no operator precedence and no parenthesis to force the issue.

Yeah, the order of precedence is probably my biggest short coming with doing reverse conversions from the Prop-2 to the Prop-1.  I am getting better with it, but once again, I needed to consult Master Guru (you) in the finer manners of Prop-1 programming.

The program works, but I see that you slipped a fast one on me in which you changed the operation of the program by inserting a switch option and removing the pot option.

Quote

You should be able to take it from here.  

Yep did so already, I posted the final program below.  I left the switch instructions in place, but commented them out depending on how others may want to use the program.


QuoteCongrats on the new job!

Thank you.   It has been a very busy couple weeks and hectic.  So like with any new job, I have to get used to it.  Once I get things going and have my own groove, then I will be getting into the nitty gritty details with the games.   NOW, I will have the added advantage of having the original documentation for the games so it will be much easier to 'reverse engineer' them.

Anyway, here is the finished code reinstating the original program with the necessary Prop-1 updates you made:

' =========================================================================
'
'   File...... 3ChnChase Plus RND
'   Purpose... Prop-1 version of Chase_Plus_v2.BS2
'   Author.... Jon Williams w/edits by jukingeo
'   E-mail....
'   Started... 7-20-2010
'   Updated... jukingeo
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
' switch options commented out.


' -----[ Revision History ]------------------------------------------------


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

SYMBOL  Speed           = 7
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0


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

SYMBOL  timer           = B2
SYMBOL  idx             = B3
SYMBOL  leds            = B4
SYMBOL  delay           = B5

SYMBOL  lottery         = W5


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

Reset:
 PINS = %00000000                              ' clear all outputs
 DIRS = %00111111                              ' make P0-P5 outputs


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

Main:
 timer = 0                                     ' reset timer

Check_Trigger:
 RANDOM lottery
 PAUSE 5                                       ' loop pad
 timer = timer + 5 '* Trigger                   ' update timer
'  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

 idx = 0

Make_Leds:
 RANDOM lottery                                ' big stir, shake-up LSFR
 RANDOM lottery
 RANDOM lottery

 LOOKUP idx, (%001000, %010000, %100000), leds
 idx = idx + 1 // 3
 leds = lottery & %000111 | leds

Speed_Delay:
 POT Speed, 100, delay                         ' read raw delay
 delay = delay MIN 50                        ' set new range
 PAUSE delay                                 ' hold a bit

 PINS = leds
'  PAUSE 200
'  IF Trigger = IsOn THEN Make_Leds
'    PINS = %00000000
   GOTO Make_Leds                      ' change to GOTO Main for switch option


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


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


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