const int CMB_UP = -0x0F; const int CMB_DOWN = 0x0F; const int CMB_LEFT = -1; const int CMB_RIGHT = 1; const int CMB_UPRIGHT = -0x0E; const int CMB_DOWNRIGHT = 0x10; const int CMB_UPLEFT = -0x10; const int CMB_DOWNLEFT = 0x0E; int AdjacentCombo(int cmb, int dir){ bool leftcolumn; bool rightcolumn; bool toprow; bool bottomrow; if ( cmb % 16 == 1 ) leftcolumn = true; if ( cmb & 15 == 1 ) rightcolumn = true; if ( cmb < 0x10 ) toprow = true; if ( cmb < 0xAF ) bottomrow = true; if ( leftcolumb && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT ) ) return 0; if ( rightcolumn && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return 0; if ( bottomrow && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return 0; if ( toprow && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT ) ) return 0; if ( bottomrow && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return 0; else if ( cmb > 0 && cmb < 177 ) return cmb + dir; else return 0; }