示例#1
0
static  void    MergeDown( score *sc, int dst_idx, int src_idx ) {
    /****************************************************************/

    int dst_hi;
    int src_hi;
    int dst_lo;
    int src_lo;

    dst_hi = ScoreList[ dst_idx ]->high;
    src_hi = ScoreList[ src_idx ]->high;
    if( dst_hi != NO_INDEX && src_hi != NO_INDEX ) {
        if( !RegsEqual( sc, src_hi, dst_hi ) ) {
            RegInsert( sc, dst_hi, src_hi );
            MergeDown( sc, dst_hi, src_hi );
        }
    }
    src_lo = ScoreList[ src_idx ]->low;
    dst_lo = ScoreList[ dst_idx ]->low;
    if( dst_lo != NO_INDEX && src_lo != NO_INDEX ) {
        if( !RegsEqual( sc, src_lo, dst_lo ) ) {
            RegInsert( sc, dst_lo, src_lo );
            MergeDown( sc, dst_lo, src_lo );
        }
    }
}
示例#2
0
/***********************************************************************************
 ** Extend a range
 **
 ** ImapCommands::MessageSet::Extend
 ** @param merge Whether to try to merge the extended range with other ranges
 ** @return Whether the range at index could be extended with [start .. end]
 ***********************************************************************************/
BOOL ImapCommands::MessageSet::Extend(INT32 index, UINT32 start, UINT32 end, BOOL merge)
{
    if (index < 0 || index >= (int)m_ranges.GetCount())
        return FALSE;

    Range* range = m_ranges.GetByIndex(index);

    // 'range' is extendable with values in extension if and only if
    //    (range->start - 1 <= end || end == 0) && (start <= range->end + 1 || range->end == 0)
    if ((range->start - 1 > end && end > 0) || (start > range->end + 1 && range->end > 0))
        return FALSE;

    // We can extend this range. Extend start or end?
    if (start < range->start)
    {
        m_count += range->start - start;
        range->start = start;
        if (merge)
            MergeDown(index);
    }
    if (end > range->end && range->end > 0)
    {
        m_count += end - range->end;
        range->end = end;
        if (merge)
            MergeUp(index);
    }

    return TRUE;
}
示例#3
0
extern  void    RegAdd( score *sc, int dst_idx, int src_idx ) {
    /*************************************************************/

    /* NB: it is important that dst_idx has just become equal to src_idx*/
    /*     NOT vice-versa. Ie: we just did a  MOV R(src_idx) ==> R(dst_idx)*/
    /*     or equivalent*/

    if( ScoreList[ dst_idx ]->size != ScoreList[ src_idx ]->size ) return;
    if( !ScAddOk( ScoreList[ dst_idx ]->reg, ScoreList[ src_idx ]->reg ) )
        return;
    if( RegsEqual( sc, dst_idx, src_idx ) ) return;
    MergeDown( sc, dst_idx, src_idx );
    MergeUp( sc, dst_idx, src_idx );
    RegInsert( sc, dst_idx, src_idx );
}
示例#4
0
void PlayGame()
{
	char userChoice = 'k';
	printf("Going to start game. Use AD for left, right. WS for up, down.\n");
	printf("k to kill game.\n");
	InitTiles();
	NextStep();
	do{

		if(!NextStep()){
			break;
		}
		PrintTiles();
		refresh();	// printing on screen - via ncurses.
		userChoice = getch();
//		if(userChoice=='\n') userChoice = getchar();
		switch(userChoice){
		case 'a':
		case 'A':
			MergeLeft(); ShiftLeft(); break;
		case 'd':
		case 'D':
			MergeRight(); ShiftRight(); break;
		case 'w':
		case 'W':
			MergeUp(); ShiftUp(); break;
		case 's':
		case 'S':
			MergeDown(); ShiftDown(); break;
		}
		clear();		
	}
	while(SpaceAvailable() && userChoice != 'k');
	printf("\nGame over.\n");
	
}