Controller B - Target State Machine
This state machine controls the state of the target system for the whole game and posts events depending on the change of state. Only events from Controller B affect the state.
InitTargetFSM
CurrentState = FirstTInit
RunTargetFSM
switch(CurrentState)
case(FirstTInit)
if ThisEvent = ES_INIT
NextState = InitTState
case(InitTState)
if ThisEvent = ES_Begin
NextState = BNotActive
case (BNotActive)
if ThisEvent = AccessCardRemoved, Stage End, or GameTimeout
NextState = InitTState
else if ThisEvent = BCovered
Brighten B LEDs
Send B Covered message to A
NextState = BHit
case (BHit)
if ThisEvent = BUncovered
NextState = BNotActive
Dim LEDs
Send B Uncovered message to A
else if ThisEvent = AccessCardRemoved, Stage End, or GameTimeout
NextState = InitTState
CurrentState = NextState
CurrentState = FirstTInit
RunTargetFSM
switch(CurrentState)
case(FirstTInit)
if ThisEvent = ES_INIT
NextState = InitTState
case(InitTState)
if ThisEvent = ES_Begin
NextState = BNotActive
case (BNotActive)
if ThisEvent = AccessCardRemoved, Stage End, or GameTimeout
NextState = InitTState
else if ThisEvent = BCovered
Brighten B LEDs
Send B Covered message to A
NextState = BHit
case (BHit)
if ThisEvent = BUncovered
NextState = BNotActive
Dim LEDs
Send B Uncovered message to A
else if ThisEvent = AccessCardRemoved, Stage End, or GameTimeout
NextState = InitTState
CurrentState = NextState