Skip to content

Commit

Permalink
Fix possible problem through wrong use pf BACK_BUTTON
Browse files Browse the repository at this point in the history
The enum BUTTONTYPE doesn't mach array indices.
  • Loading branch information
aholler committed Sep 15, 2013
1 parent 5382457 commit 46174f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lms2012/lms2012/source/lms2012.c
Expand Up @@ -108,6 +108,9 @@
#define DEBUG_TRACE_VM
#endif

// Buttons are mapped differently in the enum BUTTONTYPE and in ButtonState.
#define IDX_BACK_BUTTON BACK_BUTTON-1

//*****************************************************************************
// UI bootloader
//*****************************************************************************
Expand Down Expand Up @@ -548,8 +551,8 @@ DSPSTAT ExecuteByteCode(IP pByteCode,GP pGlobals,LP pLocals)
VMInstance.Priority = 1;

// Execute special byte code stream
UiInstance.ButtonState[BACK_BUTTON] &= ~BUTTON_LONGPRESS;
while ((*VMInstance.ObjectIp != opOBJECT_END) && (!(UiInstance.ButtonState[BACK_BUTTON] & BUTTON_LONGPRESS)))
UiInstance.ButtonState[IDX_BACK_BUTTON] &= ~BUTTON_LONGPRESS;
while ((*VMInstance.ObjectIp != opOBJECT_END) && (!(UiInstance.ButtonState[IDX_BACK_BUTTON] & BUTTON_LONGPRESS)))
{
VMInstance.DispatchStatus = NOBREAK;
VMInstance.Priority = C_PRIORITY;
Expand Down Expand Up @@ -585,7 +588,7 @@ DSPSTAT ExecuteByteCode(IP pByteCode,GP pGlobals,LP pLocals)
}
Result = VMInstance.DispatchStatus;

UiInstance.ButtonState[BACK_BUTTON] &= ~BUTTON_LONGPRESS;
UiInstance.ButtonState[IDX_BACK_BUTTON] &= ~BUTTON_LONGPRESS;

// Restore running object parameters
VMInstance.Priority = VMInstance.PrioritySave;
Expand Down

0 comments on commit 46174f8

Please sign in to comment.