From 16c61dfb799b2be142848d5e0a1e1b3002f1b22d Mon Sep 17 00:00:00 2001 From: Mark Cannon Date: Fri, 25 Mar 2011 04:01:11 -0400 Subject: [PATCH] added GetLightsField() to LightsMapper - now it'll generate a bit field from its mappings given a LightsState --- src/LightsMapper.cpp | 18 ++++++++++++++++++ src/LightsMapper.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/LightsMapper.cpp b/src/LightsMapper.cpp index 3584d9e9..d406b833 100644 --- a/src/LightsMapper.cpp +++ b/src/LightsMapper.cpp @@ -18,6 +18,24 @@ #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 diff --git a/src/LightsMapper.h b/src/LightsMapper.h index b4a1fe79..55d095c3 100644 --- a/src/LightsMapper.h +++ b/src/LightsMapper.h @@ -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 -- 2.11.0