Пример #1
0
Файл: run.c Проект: zonesan/ucos
//==================================================================================
//void	Run8ChCif(void)
//{
//	U8 _t1_, _t2_, _t3_;
//	U16 _dly_;
//	
//	_t1_ = ReadAsicByte(MASTER,DVC_PG1,0x54);
//	for(_t3_=0;_t3_<4;_t3_++){
//		if(BitClear(_t1_,BIT0<<_t3_)){														//... check strobe done
//			DLY_FOR(DLY_SW_STRB);
//			_t2_ = ReadAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_)^BIT3;
//			WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_);				//... analog switch
//			WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_|BIT2);		//... soft reset
//			if(b_ch_src == CH_SRC_LV){
//				if(BitClear(_t2_,BIT3))																	//... input A
//					WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT0<<_t3_));			//... strobe on opposite ch
//				else																								//... input B
//					WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT4<<_t3_));			//... strobe on opposite ch
//			}
//			WriteAsicByte(MASTER,DVC_PG1,0x54,(_t1_&0xf0)|(BIT0<<_t3_));					//... strobe on opposite ch
//			
//			if(_t3_ == 0)	run_8ch_cnt_ana_sw++;
//		}
//	}
//}
//==================================================================================
void	Run8ChCif(void)
{
	U8 _t1_, _t2_, _t3_;
	U16 _dly_;
	
	_t1_ = ReadAsicByte(MASTER,DVC_PG1,0x54);
	if(BitClear(_t1_,0x0f)){														//... check strobe done

		if(wndw_rc_fm_type == CIF_TYPE_FL)
			DLY_FOR(DLY_SW_STRB);												//... about 1 field when non-realtime and CIF record

		for(_t3_=0;_t3_<4;_t3_++){
			_t2_ = ReadAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_)^BIT3;
			WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_);				//... analog switch
			WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_|BIT2);		//... soft reset
			if(b_ch_src == CH_SRC_LV){
				if(BitClear(_t2_,BIT3))																	//... input A
					WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT0<<_t3_));			//... strobe on opposite ch
				else																								//... input B
					WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT4<<_t3_));			//... strobe on opposite ch
			}
			WriteAsicByte(MASTER,DVC_PG1,0x54,(_t1_&0xf0)|(BIT0<<_t3_));
			
			if(_t3_ == 0)	run_8ch_cnt_ana_sw++;
		}
//		WriteAsicByte(MASTER,DVC_PG1,0x54,(_t1_&0xf0)|0x0f);
	}
}
Пример #2
0
 int Ardb::DeleteKey(Context& ctx, const Slice& key)
 {
     ValueObject meta;
     meta.key.type = KEY_META;
     meta.key.db = ctx.currentDB;
     meta.key.key = key;
     if (0 != GetKeyValue(ctx, meta.key, &meta))
     {
         return 0;
     }
     switch (meta.type)
     {
         case SET_META:
         {
             SClear(ctx, meta);
             break;
         }
         case LIST_META:
         {
             LClear(ctx, meta);
             break;
         }
         case ZSET_META:
         {
             ZClear(ctx, meta);
             break;
         }
         case HASH_META:
         {
             HClear(ctx, meta);
             break;
         }
         case STRING_META:
         {
             DelKeyValue(ctx, meta.key);
             break;
         }
         case BITSET_META:
         {
             BitClear(ctx, meta);
             break;
         }
         default:
         {
             return 0;
         }
     }
     if (meta.meta.expireat > 0)
     {
         KeyObject expire;
         expire.type = KEY_EXPIRATION_ELEMENT;
         expire.db = ctx.currentDB;
         expire.key = key;
         expire.score.SetInt64(meta.meta.expireat);
         DelKeyValue(ctx, expire);
     }
     return 1;
 }
Пример #3
0
void IntClearFlag(u8 numinter)
{
    #if defined(UBW32_795) || defined(EMPEROR795) || defined(PIC32_PINGUINO_T795)
	if (numinter > 63)
	{
		numinter -= 64;
		BitClear(IFS2, numinter);
	}
	else if (numinter > 31 && numinter <= 63) 
    #else
	if (numinter > 31)
    #endif
	{
		numinter -= 32;
		BitClear(IFS1, numinter);
	}
	else
		BitClear(IFS0, numinter);
}
Пример #4
0
void Permute(EncryptBlk *aBlkPTr, int32_t* aKeyPtr)
{
	register char bitPos;
	char* ArrayPtr;

	register uint32_t	keyLo;
	register uint32_t	keyHi;
	register uint32_t	loBits;
	register uint32_t	hiBits;
	register uint32_t	gTestVal;
	register uint32_t	gTemp;
	register uint32_t	arrayByte;

	bitPos = 0;
	hiBits = 0;
	loBits = 0;

	keyLo = aBlkPTr->keyLo;
	keyHi = aBlkPTr->keyHi;

	ArrayPtr = (char*) aKeyPtr;
	bitPos = *ArrayPtr ++; 		/* get source bit */

Loop:
	arrayByte = bitPos;
	ROLeftLong(hiBits);

	BitTest(5, arrayByte);
	BEQ(jump20);

	BitClear(5,arrayByte);
	BitTest(arrayByte,keyLo);
	BNE(jump30);
	BRA(jump40);
		
jump20:
	BitTest(arrayByte,keyHi);
	BEQ(jump40);	
		
jump30:
	BitSet(kbit0,hiBits);

jump40:
	bitPos = *ArrayPtr++;
	if (bitPos >= 0) goto Loop;
	EXchange(hiBits,loBits);
	if ( bitPos !=  -1 ) goto jump50;
	bitPos = *ArrayPtr++;
	goto Loop;
		
jump50:
	aBlkPTr->keyLo = loBits; /* low bits */
	aBlkPTr->keyHi = hiBits;
}
Пример #5
0
Bitfield& Bitfield::operator =(bool t)
{
    if (t)
        {
            BitSet(_flag, _position);
        }
    else
        {
            BitClear(_flag, _position);
        }

    return *this;
}
Пример #6
0
void CMotionControl::SetRotate2D(axis_t axis, float rad)
{
	if (rad != 0.0)
	{
		if (axis==Y_AXIS) rad = -rad;
		BitSet(_rotateEnabled2D,axis);
		_rotate2D[axis].Set(rad);
	}
	else
	{
		BitClear(_rotateEnabled2D,axis);
	}
}
Пример #7
0
Файл: run.c Проект: zonesan/ucos
//==================================================================================
//
//==================================================================================
void	Run8ChFast(void)
{
	U8 _t1_, _t2_, _t3_;
//	U16 _dly_;
	
	_t1_ = ReadAsicByte(MASTER,DVC_PG1,0x04);
	for(_t3_=0;_t3_<4;_t3_++){
		_t2_ = ReadAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_);
		if(BitClear(_t2_,BIT3)){																	//... input A
			if(BitClear(_t1_,BIT0<<_t3_)){														//... check strobe done
//				DLY_FOR(DLY_SW_STRB);
				_t2_ |= BIT3;																			//... change to input B
				WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_);				//... analog switch
				WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_|BIT2);		//... soft reset
//				WriteAsicByte(MASTER,DVC_PG1,0x04,_t1_|(BIT4<<_t3_));			//... strobe on opposite ch
				WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT4<<_t3_));			//... strobe on opposite ch
//				WriteAsicByte(MASTER,DVC_PG1,0x54,(BIT0<<_t3_));					//... strobe on opposite ch
				
				if(_t3_ == 0)	run_8ch_cnt_ana_sw++;
			}
		}
		else{																								//... input B
			if(BitClear(_t1_,BIT4<<_t3_)){														//... check strobe done
//				DLY_FOR(DLY_SW_STRB);
				_t2_ &= ~BIT3;																			//... change to input A
				WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_);				//... analog switch
				WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t3_,_t2_|BIT2);		//... soft reset
//				WriteAsicByte(MASTER,DVC_PG1,0x04,_t1_|(BIT0<<_t3_));			//... strobe on opposite ch
				WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT0<<_t3_));			//... strobe on opposite ch
//				WriteAsicByte(MASTER,DVC_PG1,0x54,(BIT0<<_t3_));					//... strobe on opposite ch
				
				if(_t3_ == 0)	run_8ch_cnt_ana_sw++;
			}
		}
	}
}
Пример #8
0
typeMoveList *MyPositionalGain(typePos *Position, typeMoveList *List, int av)
{
    uint64 empty = ~Position->OccupiedBW, U, T;
    int to, sq;
    typeMoveList *sm, *p, *q;
    int move;
    sm = List;
    for (U = ForwardShift(BitboardMyP & SecondSixthRanks) & empty; U; BitClear(sq, U))
    {
        to = BSF(U);
        if (OnThirdRank(to) && Position->sq[Forward(to)] == 0)
            AddGain(List, (Backward(to) << 6) | Forward(to), EnumMyP, Forward(to));
        AddGain(List, (Backward(to) << 6) | to, EnumMyP, to);
    }
    for (U = BitboardMyN; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttN[sq] & empty;
        AddGainTo(T, EnumMyN);
    }
    for (U = BitboardMyBL; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttB(sq) & empty;
        AddGainTo(T, EnumMyBL);
    }
    for (U = BitboardMyBD; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttB(sq) & empty;
        AddGainTo(T, EnumMyBD);
    }
    for (U = BitboardMyR; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttR(sq) & empty;
        AddGainTo(T, EnumMyR);
    }
    for (U = BitboardMyQ; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttQ(sq) & empty;
        AddGainTo(T, EnumMyQ);
    }
    sq = MyKingSq;
    T = AttK[sq] & empty &(~OppAttacked);
    AddGainTo(T, EnumMyK);
    List->move = 0;
    Sort;
    return List;
}
Пример #9
0
VMK_ReturnStatus
LogFS_CheckPointCommit(LogFS_MetaLog *ml,
      LogFS_CheckPoint *cp, 
      int buffer,
      disk_block_t superTreeRoot,
      List_Links *movedNodes)
{
   VMK_ReturnStatus status;
   List_Links *elem, *next;

   cp->superTreeRoot = superTreeRoot;

   /* Apply changes to the checkpoint's copy of the node allocation bitmap. */

   LIST_FORALL(movedNodes, elem) {
      MovedNode *fn = List_Entry(elem, MovedNode, list);
      BitClear(cp->nodesBitmap, fn->from);
      BitSet(cp->nodesBitmap, fn->to);
   }
Пример #10
0
Файл: run.c Проект: zonesan/ucos
//==================================================================================
void	Run8ChMux(void)
//... frame by frame
//... Auto strobe pseudo 8 ch & Mux
//... use mux interrupt, not use que & internal trigger mode(period:01h).
//... FLDENC signal interrupt
{
	U8 _t1_, _t2_;//, _t3_;
	
	if(run_8ch_cnt_mux < 3)	run_8ch_cnt_mux++;
	else	run_8ch_cnt_mux = 0;
	
	if(run_8ch_cnt_mux == 0)	run_8ch_cnt_ana_sw++;

	if(run_8ch_cnt_mux == 0)		_t1_ = 2;
	else if(run_8ch_cnt_mux == 1)	_t1_ = 3;
	else if(run_8ch_cnt_mux == 2)	_t1_ = 0;
	else	_t1_ = 1;

	_t2_ = ReadAsicByte(MASTER,DVC_PG1,0x59);
	WriteAsicByte(MASTER,DVC_PG1,0x59,(_t2_&0xf0)|BIT4|run_8ch_cnt_mux);	//... mux interrupt
	_t2_ = ReadAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t1_)^BIT3;
	WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t1_,_t2_);								//... ANA_SW
	WriteAsicByte(MASTER,DVC_PG0,0x0d+0x10*_t1_,_t2_|BIT2);							//... SW_RESET

	if(b_ch_src == CH_SRC_LV){
//		_t3_ = ReadAsicByte(MASTER,DVC_PG1,REG_FUNC_MODE_X+(_t1_<<3));// ^ DMCH_PATH;
//		IfBitSet(_t2_,BIT2)	SetBit(_t3_,DMCH_PATH);//BIT2);						//... dummy channel
//		else	ClearBit(_t3_,DMCH_PATH);//BIT2);													//... main channel
//		WriteAsicByte(MASTER,DVC_PG1,REG_FUNC_MODE_X+(_t1_<<3),_t3_);
//
//		_t1_ = ReadAsicByte(MASTER,DVC_PG1,REG_STRB_CTL_X);
//		WriteAsicByte(MASTER,DVC_PG1,REG_STRB_CTL_X,(_t2_&0xf0)|(BIT0<<run_8ch_cnt_mux));						//... SW_RESET|ANA_SW
		if(BitClear(_t2_,BIT3))																	//... input A
			WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT0<<run_8ch_cnt_mux));			//... strobe on opposite ch
		else																								//... input B
			WriteAsicByte(MASTER,DVC_PG1,0x04,(BIT4<<run_8ch_cnt_mux));			//... strobe on opposite ch
	}
}
Пример #11
0
 LIST_FORALL_SAFE(movedNodes, elem, next) {
    MovedNode *fn = List_Entry(elem, MovedNode, list);
    BitClear(nodesBitmap, fn->from);
    List_Remove(elem);
    free(fn);
 }
Пример #12
0
typeMoveList *MyQuietChecks(typePos *Position, typeMoveList *List, uint64 mask)
{
    int opks, king, sq, to, fr, pi;
    uint64 U, T, V;
    typeMoveList *list;
    uint32 move;
    uint64 gcm;
    gcm = ~MyXray;
    mask = (~mask) &~MyOccupied;
    ;
    list = List;
    king = OppKingSq;
    list = List;
    for (U = MyXray & MyOccupied; U; BitClear(fr, U))
    {
        fr = BSF(U);
        pi = Position->sq[fr];
        if (pi == EnumMyP)
        {
            if (File(fr) != File(king) && !SeventhRank(fr) && Position->sq[Forward(fr)] == 0)
            {
                (List++)->move = (fr << 6) | Forward(fr);
                if (OnSecondRank(fr) && Position->sq[Forward2(fr)] == 0)
                    (List++)->move = (fr << 6) | Forward2(fr);
            }
            if (CanCaptureRight && Rank(fr) != NumberRank7)
                (List++)->move = (fr << 6) | ForwardRight(fr);
            if (CanCaptureLeft && Rank(fr) != NumberRank7)
                (List++)->move = (fr << 6) | ForwardLeft(fr);
        }
        else if (pi == EnumMyN)
        {
            V = AttN[fr] & mask;
            while (V)
            {
                to = BSF(V);
                (List++)->move = (fr << 6) | to;
                BitClear(to, V);
            }
        }
        else if (pi == EnumMyBL || pi == EnumMyBD)
        {
            V = AttB(fr) & mask;
            while (V)
            {
                to = BSF(V);
                (List++)->move = (fr << 6) | to;
                BitClear(to, V);
            }
        }
        else if (pi == EnumMyR)
        {
            V = AttR(fr) & mask;
            while (V)
            {
                to = BSF(V);
                (List++)->move = (fr << 6) | to;
                BitClear(to, V);
            }
        }
        else if (pi == EnumMyK)
        {
            if (File(fr) == File(king) || Rank(fr) == Rank(king))
                V = AttK[fr] & NonOrtho[king] & mask &(~OppAttacked);
            else
                V = AttK[fr] & NonDiag[king] & mask &(~OppAttacked);
            while (V)
            {
                to = BSF(V);
                (List++)->move = (fr << 6) | to;
                BitClear(to, V);
            }
        }
    }
    opks = OppKingSq;
    T = CaptureLeft &(~BitBoardEighthRank) & mask & OppOccupied & MyAttackedPawns[opks];
    while (T)
    {
        to = BSF(T);
        (List++)->move = FromRight(to) | to;
        BitClear(to, T);
    }
    T = CaptureRight &(~BitBoardEighthRank) & mask & OppOccupied & MyAttackedPawns[opks];
    while (T)
    {
        to = BSF(T);
        (List++)->move = FromLeft(to) | to;
        BitClear(to, T);
    }
    for (U = BitboardMyQ; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttQ(sq) & AttQ(king) & mask;
        while (T)
        {
            to = BSF(T);
            BitClear(to, T);
            if ((OppAttackedPawns[to] & BitboardOppP & gcm) == 0 && (AttN[to] & BitboardOppN & gcm) == 0)
            {
                move = (sq << 6) | to;
                if (MySEE(Position, move))
                    (List++)->move = (sq << 6) | to;
            }
        }
    }
    for (U = BitboardMyR; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttR(sq) & AttR(king) & mask;
        while (T)
        {
            to = BSF(T);
            BitClear(to, T);
            if ((OppAttackedPawns[to] & BitboardOppP & gcm) == 0 && (AttN[to] & BitboardOppN & gcm) == 0)
            {
                move = (sq << 6) | to;
                if (MySEE(Position, move))
                    (List++)->move = (sq << 6) | to;
            }
        }
    }
    for (U = BitboardMyB; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttB(sq) & AttB(king) & mask;
        while (T)
        {
            to = BSF(T);
            BitClear(to, T);
            if ((OppAttackedPawns[to] & BitboardOppP & gcm) == 0)
            {
                move = (sq << 6) | to;
                if (MySEE(Position, move))
                    (List++)->move = (sq << 6) | to;
            }
        }
    }
    for (U = BitboardMyN; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttN[sq] & AttN[king] & mask;
        while (T)
        {
            to = BSF(T);
            BitClear(to, T);
            if ((OppAttackedPawns[to] & BitboardOppP & gcm) == 0)
            {
                move = (sq << 6) | to;
                if (MySEE(Position, move))
                    (List++)->move = (sq << 6) | to;
            }
        }
    }
    if (BitboardOppK & FourthEighthRankNoH && Position->sq[BackRight(opks)] == 0)
    {
        if (Position->sq[BackRight2(opks)] == EnumMyP)
        {
            fr = BackRight2(opks);
            to = BackRight(opks);
            move = (fr << 6) | to;
            if (PawnGuard(to, fr) && MySEE(Position, move))
                (List++)->move = move;
        }
        if (Rank(opks) == NumberRank5 && Position->sq[BackRight2(opks)] == 0
                && Position->sq[BackRight3(opks)] == EnumMyP)
        {
            to = BackRight(opks);
            fr = BackRight3(opks);
            move = (fr << 6) | to;
            if (PawnGuard(to, fr) && MySEE(Position, move))
                (List++)->move = move;
        }
    }
    if (BitboardOppK & FourthEighthRankNoA && Position->sq[BackLeft(opks)] == 0)
    {
        if (Position->sq[BackLeft2(opks)] == EnumMyP)
        {
            fr = BackLeft2(opks);
            to = BackLeft(opks);
            move = (fr << 6) | to;
            if (PawnGuard(to, fr) && MySEE(Position, move))
                (List++)->move = move;
        }
        if (Rank(opks) == NumberRank5 && Position->sq[BackLeft2(opks)] == 0
                && Position->sq[BackLeft3(opks)] == EnumMyP)
        {
            to = BackLeft(opks);
            fr = BackLeft3(opks);
            move = (fr << 6) | to;
            if (PawnGuard(to, fr) && MySEE(Position, move))
                (List++)->move = move;
        }
    }
    List->move = MoveNone;
    return List;
}
Пример #13
0
typeMoveList *MyOrdinary(typePos *Position, typeMoveList *List)
{
    uint64 empty = ~Position->OccupiedBW, U, T, Rook, Bishop, Pawn;
    int to, sq, opks = OppKingSq;
    if (CastleOO && ((Position->OccupiedBW | OppAttacked) & WhiteF1G1) == 0)
        MoveAdd(List, FlagOO | (WhiteE1 << 6) | WhiteG1, EnumMyK, WhiteG1, 0);
    if (CastleOOO && (Position->OccupiedBW & WhiteB1C1D1) == 0 && (OppAttacked & WhiteC1D1) == 0)
        MoveAdd(List, FlagOO | (WhiteE1 << 6) | WhiteC1, EnumMyK, WhiteC1, 0);
    Pawn = MyAttackedPawns[opks];
    if (BitboardMyQ | BitboardMyR)
        Rook = AttR(opks);
    if (BitboardMyQ | BitboardMyB)
        Bishop = AttB(opks);
    for (U = ForwardShift(BitboardMyP & SecondSixthRanks) & empty; U; BitClear(sq, U))
    {
        to = BSF(U);
        if (OnThirdRank(to) && Position->sq[Forward(to)] == 0)
            MoveAdd(List, (Backward(to) << 6) | Forward(to), EnumMyP, Forward(to), Pawn);
        MoveAdd(List, (Backward(to) << 6) | to, EnumMyP, to, Pawn);
    }
    for (U = BitboardMyQ; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttQ(sq) & empty;
        MovesTo(T, EnumMyQ, Rook | Bishop);
    }
    for (U = BitboardMyR; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttR(sq) & empty;
        MovesTo(T, EnumMyR, Rook);
    }
    for (U = BitboardMyB; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttB(sq) & empty;
        MovesTo(T, ((SqSet[sq] & Black) ? EnumMyBD : EnumMyBL), Bishop);
    }
    sq = BSF(BitboardMyK);
    T = AttK[sq] & empty &(~OppAttacked);
    MovesTo(T, EnumMyK, 0);
    for (U = BitboardMyN; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttN[sq] & empty;
        MovesTo(T, EnumMyN, AttN[opks]);
    }
    for (U = BitboardMyP & BitBoardSeventhRank; U; BitClear(sq, U))
    {
        sq = BSF(U);
        to = Forward(sq);
        if (Position->sq[to] == 0)
            UnderProm();
        to = ForwardLeft(sq);
        if (sq != WhiteA7 && SqSet[to] & OppOccupied)
            UnderProm();
        to = ForwardRight(sq);
        if (sq != WhiteH7 && SqSet[to] & OppOccupied)
            UnderProm();
    }
    List->move = 0;
    return List;
}
Пример #14
0
typeMoveList *MyCapture(typePos *Position, typeMoveList *List, uint64 mask)
{
    uint64 U, T, AttR, AttB;
    int sq, to, c;
    to = Position->Dyn->ep;
    if (to)
    {
        if (CaptureLeft & SqSet[to])
            Add(List, FlagEP | FromRight(to) | to, CaptureEP);
        if (CaptureRight & SqSet[to])
            Add(List, FlagEP | FromLeft(to) | to, CaptureEP);
    }
    if ((mask & MyAttacked) == 0)
        goto NoTarget;
    T = CaptureLeft &(~BitBoardEighthRank) & mask;
    while (T)
    {
        to = BSF(T);
        c = Position->sq[to];
        Add(List, FromRight(to) | to, CaptureValue[EnumMyP][c]);
        BitClear(to, T);
    }
    T = CaptureRight &(~BitBoardEighthRank) & mask;
    while (T)
    {
        to = BSF(T);
        c = Position->sq[to];
        Add(List, FromLeft(to) | to, CaptureValue[EnumMyP][c]);
        BitClear(to, T);
    }
    for (U = BitboardMyN; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttN[sq] & mask;
        AddTo(T, CaptureValue[EnumMyN][c]);
    }
    for (U = BitboardMyB; U; BitClear(sq, U))
    {
        sq = BSF(U);
        AttB = AttB(sq);
        T = AttB & mask;
        AddTo(T, CaptureValue[EnumMyBL][c]);
    }
    for (U = BitboardMyR; U; BitClear(sq, U))
    {
        sq = BSF(U);
        AttR = AttR(sq);
        T = AttR & mask;
        AddTo(T, CaptureValue[EnumMyR][c]);
    }
    for (U = BitboardMyQ; U; BitClear(sq, U))
    {
        sq = BSF(U);
        AttR = AttR(sq);
        AttB = AttB(sq);
        T = (AttB | AttR) & mask;
        AddTo(T, CaptureValue[EnumMyQ][c]);
    }
    sq = BSF(BitboardMyK);
    T = AttK[sq] & mask &(~OppAttacked);
    AddTo(T, CaptureValue[EnumMyK][c]);
NoTarget:
    for (U = BitboardMyP & BitBoardSeventhRank; U; BitClear(sq, U))
    {
        sq = BSF(U);
        to = Forward(sq);
        if (Position->sq[to] == 0)
        {
            Add(List, FlagPromQ | (sq << 6) | to, PtoQ);
            if (AttN[to] & BitboardOppK)
                Add(List, FlagPromN | (sq << 6) | to, PtoN);
        }
        to = ForwardLeft(sq);
        if (sq != WhiteA7 && SqSet[to] & mask)
        {
            c = Position->sq[to];
            Add(List, FlagPromQ | (sq << 6) | to, PromQueenCap);
            if (AttN[to] & BitboardOppK)
                Add(List, FlagPromN | (sq << 6) | to, PromKnightCap);
        }
        to = ForwardRight(sq);
        if (sq != WhiteH7 && SqSet[to] & mask)
        {
            c = Position->sq[to];
            Add(List, FlagPromQ | (sq << 6) | to, PromQueenCap);
            if (AttN[to] & BitboardOppK)
                Add(List, FlagPromN | (sq << 6) | to, PromKnightCap);
        }
    }
    List->move = 0;
    return List;
}
Пример #15
0
typeMoveList *MyEvasion(typePos *Position, typeMoveList *List, uint64 c2)
{
    uint64 U, T, att, mask;
    int sq, to, fr, c, king, pi;
    king = MyKingSq;
    att = MyKingCheck;
    sq = BSF(att);
    pi = Position->sq[sq];
    mask = (~OppAttacked) &(((pi == EnumOppP) ? AttK[king] : 0) | Evade(king, sq)) & (~MyOccupied) &c2;
    BitClear(sq, att);
    if (att)
    {
        sq = BSF(att);
        pi = Position->sq[sq];
        mask = mask &(PieceIsOppPawn(pi) | Evade(king, sq));
        sq = king;
        AddTo(mask, CaptureValue[EnumMyK][c]);
        List->move = 0;
        return List;
    }
    c2 &= InterPose(king, sq);
    sq = king;
    AddTo(mask, CaptureValue[EnumMyK][c]);
    if (!c2)
    {
        List->move = 0;
        return List;
    }
    if (CaptureRight &(c2 & OppOccupied))
    {
        to = BSF(c2 & OppOccupied);
        c = Position->sq[to];
        if (EighthRank(to))
        {
            Add(List, FlagPromQ | FromLeft(to) | to, (0x20 << 24) + CaptureValue[EnumMyP][c]);
            Add(List, FlagPromN | FromLeft(to) | to, 0);
            Add(List, FlagPromR | FromLeft(to) | to, 0);
            Add(List, FlagPromB | FromLeft(to) | to, 0);
        }
        else
            Add(List, FromLeft(to) | to, CaptureValue[EnumMyP][c]);
    }
    if (CaptureLeft &(c2 & OppOccupied))
    {
        to = BSF(c2 & OppOccupied);
        c = Position->sq[to];
        if (EighthRank(to))
        {
            Add(List, FlagPromQ | FromRight(to) | to, (0x20 << 24) + CaptureValue[EnumMyP][c]);
            Add(List, FlagPromN | FromRight(to) | to, 0);
            Add(List, FlagPromR | FromRight(to) | to, 0);
            Add(List, FlagPromB | FromRight(to) | to, 0);
        }
        else
            Add(List, FromRight(to) | to, CaptureValue[EnumMyP][c]);
    }
    to = Position->Dyn->ep;
    if (to)
    {
        if (CaptureRight & SqSet[to] && SqSet[Backward(to)] & c2)
            Add(List, FlagEP | FromLeft(to) | to, CaptureValue[EnumMyP][EnumOppP]);
        if (CaptureLeft & SqSet[to] && SqSet[Backward(to)] & c2)
            Add(List, FlagEP | FromRight(to) | to, CaptureValue[EnumMyP][EnumOppP]);
    }
    T = BitboardMyP & BackShift((c2 & OppOccupied) ^ c2);
    while (T)
    {
        fr = BSF(T);
        BitClear(fr, T);
        if (SeventhRank(fr))
        {
            Add(List, FlagPromQ | (fr << 6) | Forward(fr), CaptureValue[EnumMyP][0]);
            Add(List, FlagPromN | (fr << 6) | Forward(fr), 0);
            Add(List, FlagPromR | (fr << 6) | Forward(fr), 0);
            Add(List, FlagPromB | (fr << 6) | Forward(fr), 0);
        }
        else
            Add(List, (fr << 6) | Forward(fr), CaptureValue[EnumMyP][0]);
    }
    T = BitboardMyP & BackShift2((c2 & OppOccupied) ^ c2) & SecondRank & BackShift(~Position->OccupiedBW);
    while (T)
    {
        fr = BSF(T);
        BitClear(fr, T);
        Add(List, (fr << 6) | Forward2(fr), CaptureValue[EnumMyP][0]);
    }
    for (U = BitboardMyN; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttN[sq] & c2;
        AddTo(T, CaptureValue[EnumMyN][c]);
    }
    for (U = BitboardMyB; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttB(sq) & c2;
        AddTo(T, CaptureValue[EnumMyBL][c]);
    }
    for (U = BitboardMyR; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttR(sq) & c2;
        AddTo(T, CaptureValue[EnumMyR][c]);
    }
    for (U = BitboardMyQ; U; BitClear(sq, U))
    {
        sq = BSF(U);
        T = AttQ(sq) & c2;
        AddTo(T, CaptureValue[EnumMyQ][c]);
    }
    List->move = 0;
    return List;
}