added GetLightsField() to LightsMapper - now it'll generate a bit field from its...
authorMark Cannon <vyhdycokio@gmail.com>
Fri, 25 Mar 2011 08:01:11 +0000 (04:01 -0400)
committerMark Cannon <vyhdycokio@gmail.com>
Fri, 25 Mar 2011 08:01:11 +0000 (04:01 -0400)
src/LightsMapper.cpp
src/LightsMapper.h

index 3584d9e..d406b83 100644 (file)
 
 #define LIGHTS_INI_PATH "Data/LightsMaps.ini"
 
+uint32_t LightsMapping::GetLightsField( const LightsState *ls ) const
+{
+       uint32_t ret = 0;
+
+       FOREACH_CabinetLight( cl )
+               if( ls->m_bCabinetLights[cl] )
+                       ret |= m_iCabinetLights[cl];
+
+       FOREACH_GameController( gc )
+               FOREACH_GameButton( gb )
+                       if( ls->m_bGameButtonLights[gc][gb] )
+                               ret |= m_iGameLights[gc][gb];
+
+       ret |= m_iCoinCounter[ls->m_bCoinCounter ? 1 : 0];
+
+       return ret;
+}
+
 /* It is important to note that ToMapping writes to the
  * input; FromMapping does not. This is because we never
  * have a reason to convert a LightsMapping value to a
index b4a1fe7..55d095c 100644 (file)
@@ -50,6 +50,9 @@ struct LightsMapping
                m_iCoinCounter[1] = array[1];   // on state
        }
 
+       /* returns the bit field using these mappings with the given state */
+       uint32_t GetLightsField( const LightsState *ls ) const;
+
        uint32_t        m_iCabinetLights[NUM_CABINET_LIGHTS];
        uint32_t        m_iGameLights[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS];
        uint32_t        m_iCoinCounter[2];      // off, on