uint64_t pawnAtk(int sq, int color) { uint64_t ret = 0; int x = GetX(sq); int y = GetY(sq); if (color == 0) { if (Valid(x+1) && Valid(y+1)) { ret |= Bit(Sq(x+1, y+1)); } if (Valid(x-1) && Valid(y+1)) { ret |= Bit(Sq(x-1, y+1)); } } else { if (Valid(x+1) && Valid(y-1)) { ret |= Bit(Sq(x+1, y-1)); } if (Valid(x-1) && Valid(y-1)) { ret |= Bit(Sq(x-1, y-1)); } } return ret; }
int ocrdma_query_ah(struct ib_ah *ibah, struct ib_ah_attr *attr) { struct ocrdma_ah *ah = get_ocrdma_ah(ibah); struct ocrdma_av *av = ah->av; struct ocrdma_grh *grh; attr->ah_flags |= IB_AH_GRH; if (ah->av->valid & Bit(1)) { grh = (struct ocrdma_grh *)((u8 *)ah->av + sizeof(struct ocrdma_eth_vlan)); attr->sl = be16_to_cpu(av->eth_hdr.vlan_tag) >> 13; } else {
void PrintBB(uint64_t b) { for (int y = 7; y >= 0; --y) { for (int x = 0; x < 8; ++x) { std::cout << ((b & Bit(Sq(x, y))) ? "1" : "0") << " "; } std::cout << std::endl; } }
uint64_t knightAtk(int sq) { uint64_t ret = 0; int x = GetX(sq); int y = GetY(sq); if (Valid(x+1) && Valid(y+2)) { ret |= Bit(Sq(x+1, y+2)); } if (Valid(x+1) && Valid(y-2)) { ret |= Bit(Sq(x+1, y-2)); } if (Valid(x-1) && Valid(y+2)) { ret |= Bit(Sq(x-1, y+2)); } if (Valid(x-1) && Valid(y-2)) { ret |= Bit(Sq(x-1, y-2)); } if (Valid(x+2) && Valid(y+1)) { ret |= Bit(Sq(x+2, y+1)); } if (Valid(x+2) && Valid(y-1)) { ret |= Bit(Sq(x+2, y-1)); } if (Valid(x-2) && Valid(y+1)) { ret |= Bit(Sq(x-2, y+1)); } if (Valid(x-2) && Valid(y-1)) { ret |= Bit(Sq(x-2, y-1)); } return ret; }
uint64_t kingAtk(int sq) { uint64_t ret = 0; int x = GetX(sq); int y = GetY(sq); if (Valid(x+1) && Valid(y+1)) { ret |= Bit(Sq(x+1, y+1)); } if (Valid(x+1) && Valid(y-1)) { ret |= Bit(Sq(x+1, y-1)); } if (Valid(x-1) && Valid(y+1)) { ret |= Bit(Sq(x-1, y+1)); } if (Valid(x-1) && Valid(y-1)) { ret |= Bit(Sq(x-1, y-1)); } if (Valid(x) && Valid(y+1)) { ret |= Bit(Sq(x, y+1)); } if (Valid(x) && Valid(y-1)) { ret |= Bit(Sq(x, y-1)); } if (Valid(x+1) && Valid(y)) { ret |= Bit(Sq(x+1, y)); } if (Valid(x-1) && Valid(y)) { ret |= Bit(Sq(x-1, y)); } return ret; }
uint64_t pawnMove2(int sq, int color) { uint64_t ret = 0; int x = GetX(sq); int y = GetY(sq); if (color == 0) { if (Valid(x) && Valid(y+2)) { ret |= Bit(Sq(x, y+2)); } } else { if (Valid(x) && Valid(y-2)) { ret |= Bit(Sq(x, y-2)); } } return ret; }
void PrintRanks() { for (int y = 0; y < 8; ++y) { uint64_t bb = 0; for (int x = 0; x < 8; ++x) { bb |= Bit(Sq(x, y)); } //PrintBB(bb); std::cout << "0x" << std::hex << std::setfill('0') << std::setw(16) << bb << "ULL, " << std::endl; } }
static void Command_Init(void) { //the format of the COMMAND_PING command_ping[0] = COMMAND_PING; //the format of the COMMAND_GET_STATUS command_get_status[0] = COMMAND_GET_STATUS; // the format of the COMMAND_DOWNLOAD command_download[0] = COMMAND_DOWNLOAD; command_download[1] = Bit(Program_Address, 24); command_download[2] = Bit(Program_Address, 16); command_download[3] = Bit(Program_Address, 8); command_download[4] = Bit(Program_Address, 0); command_download[5] = Bit(Program_Size, 24); command_download[6] = Bit(Program_Size, 16); command_download[7] = Bit(Program_Size, 8); command_download[8] = Bit(Program_Size, 0); //the format of the COMMAND_SEND_DATA command_send_data[0] = COMMAND_SEND_DATA; }
BitBucket::BitBucket (std::string filePath) { std::ifstream file (filePath); if(!file.is_open()) { std::cout << "Error, cannot open file " << filePath << std::endl; return; } std::string line; while(!file.eof()) { getline (file, line); /* * Format is: * type name value * type name value * ... */ // Find first space, everything up to that is the type int spaceIndex = line.find_first_of(' '); std::string type = line.substr(0, spaceIndex); // Cut what we already found from the string, continue with "name value". Everything up to the first space is the name line = line.substr(spaceIndex + 1); spaceIndex = line.find_first_of(' '); std::string key = line.substr(0, spaceIndex); // Cut everything before the value, and use that line = line.substr(spaceIndex + 1); std::string value = line; (*this)[key] = Bit(type, value); } file.close(); }
static bool ics189x_stat(eth_phy_access_t *f, int *state) { unsigned short phy_state; int tries; // Read negotiated state from the Quick Poll Detailed Status Register if (_eth_phy_read(f, 17, f->phy_addr, &phy_state)) { if ((phy_state & Bit(4)) == 0) { eth_phy_printf("... waiting for auto-negotiation"); for (tries = 0; tries < CYGINT_DEVS_ETH_PHY_AUTO_NEGOTIATION_TIME; tries++) { if (_eth_phy_read(f, 17, f->phy_addr, &phy_state)) { if ((phy_state & Bit(4)) != 0) { break; } } CYGACC_CALL_IF_DELAY_US(1000000); // 1 second eth_phy_printf("."); } eth_phy_printf("\n"); } if ((phy_state & Bit(4)) != 0) { *state = 0; if (phy_state & Bit(0)) *state |= ETH_PHY_STAT_LINK; if (phy_state & Bit(14)) *state |= ETH_PHY_STAT_FDX; if (phy_state & Bit(15)) *state |= ETH_PHY_STAT_100MB; return true; } } return false; }
{//control object num records. sizeof(ImgButtonCon)/sizeof(IMG_BUTTON_OBJ), //number of image touch control object 0,//sizeof(CharButtonCon)/sizeof(CHAR_BUTTON_OBJ), //number of char touch control object, 0,//number of dynamic image touch control object 0,//number of dynamic char touch control object 0,//number of yes no control object 0,//number of num box control object 0,//number of string option control object }, ImgButtonCon, //image touch ctrl obj CharButtonCon,//char touch ctrl obj SystemHandler,//handler of system event PeripheralsHandler,//handler of Peripherals event Bit(Perip_KeyPress)|Bit(Perip_KeyRelease)|Bit(Perip_UartInput),//mask bits of peripherals event ButtonHandler,//handler of all touch control object YesNoHandler,//handler of yes no control object NumCtrlObjHandler,//handler of num control object StrCtrlObjHandler,//handler of string control object }; //-----------------------本页自定义变量声明----------------------- typedef struct{ bool Tip; u32 GlobaU32Value; void *pGlobaPointer; }TestPage_VARS;//本页范围内的全局变量全部定义在这个结构体里面,并通过gpTestPageVars访问,可节省RAM占用 static TestPage_VARS *gpTestPageVars; //-----------------------本页自定义函数-----------------------
void SetBit( unsigned int bit ) { storage[ Field( bit ) ] |= (uint32)DL_BIT( Bit( bit ) ); }
bool IsSet ( unsigned int bit ) { return ( storage[ Field( bit ) ] & (uint32)DL_BIT( Bit( bit ) ) ) != 0; }
__attribute__((weak)) frost$core$Bit org$frostlang$frostc$Compiler$Message$$EQ$org$frostlang$frostc$Compiler$Message$R$frost$core$Bit$shim(org$frostlang$frostc$Compiler$Message* p0, frost$core$Equatable* p1) { frost$core$Bit result = org$frostlang$frostc$Compiler$Message$$EQ$org$frostlang$frostc$Compiler$Message$R$frost$core$Bit(p0, ((org$frostlang$frostc$Compiler$Message*) p1)); return result; }
__attribute__((weak)) frost$core$Bit org$frostlang$frostc$Main$Format$$EQ$org$frostlang$frostc$Main$Format$R$frost$core$Bit$shim(frost$core$Object* p0, frost$core$Equatable* p1) { frost$core$Bit result = org$frostlang$frostc$Main$Format$$EQ$org$frostlang$frostc$Main$Format$R$frost$core$Bit(((org$frostlang$frostc$Main$Format$wrapper*) p0)->value, ((org$frostlang$frostc$Main$Format$wrapper*) p1)->value); return result; }
NORMAL_PAGE, 0,// { sizeof(ImgButtonCon)/sizeof(IMG_BUTTON_OBJ), //size of touch region array 0,//sizeof(CharButtonCon)/sizeof(CHAR_BUTTON_OBJ), //size of touch region array, 0, 0, 1, }, ImgButtonCon, //touch region array NULL, SystemEventHandler, PeripheralsHandler, Bit(Perip_KeyPress)|Bit(Perip_KeyRelease)|Bit(Perip_QWebJoin)|Bit(Perip_QWebQueryName)| Bit(Perip_QWebRecv)|Bit(Perip_QWebSendFailed)|Bit(Perip_QWebSendOk)|Bit(Perip_Timer)| Bit(Perip_UartInput), ButtonHandler, YesNoHandler, }; //-----------------------本页自定义变量声明----------------------- typedef struct{ u8 Addr;//记录地址 u8 DispIdx;//记录排到列表第几个位置,从1开始 bool IsHiLight;//设备名是否高亮 u16 NameChk;//名字校验码 u8 Name[DEVICE_NAME_MAX_LEN];//记录名字 }CLIENT_RECORD;
__attribute__((weak)) frost$core$Bit org$frostlang$json$Token$Kind$$EQ$org$frostlang$json$Token$Kind$R$frost$core$Bit$shim(frost$core$Object* p0, frost$core$Equatable* p1) { frost$core$Bit result = org$frostlang$json$Token$Kind$$EQ$org$frostlang$json$Token$Kind$R$frost$core$Bit(((org$frostlang$json$Token$Kind$wrapper*) p0)->value, ((org$frostlang$json$Token$Kind$wrapper*) p1)->value); return result; }
const PAGE_ATTRIBUTE AppListPage={ "AppListPage", "YuanYin", "Page Description", NORMAL_PAGE, 0,// { sizeof(ImgButtonCon)/sizeof(IMG_BUTTON_OBJ), //size of touch region array sizeof(CharButtonCon)/sizeof(CHAR_BUTTON_OBJ), //size of touch region array, }, ImgButtonCon, //touch region array CharButtonCon, SystemEventHandler, PeripheralsHandler, Bit(Perip_KeyPress)|Bit(Perip_KeyRelease)|Bit(Perip_UartInput), ButtonHandler, }; //-----------------------本页自定义变量声明----------------------- typedef enum{ OSID_NULL=0,//ID号不能为0 OSID_SYS, OSID_CLOCK, OSID_ALARM, }OPTIONS_ID; typedef enum{ SYSOP_UseUsbOutput=1,//不能从0开始 SYSOP_LightTime,
NORMAL_PAGE, //type,must be page or app 0, { sizeof(ImgButtonCon)/sizeof(IMG_BUTTON_OBJ), //size of touch region array 0,//sizeof(CharButtonCon)/sizeof(CHAR_BUTTON_OBJ), //size of touch region array, 0,0, 1,3,2 }, ImgButtonCon, //touch region array NULL,//CharButtonCon, SystemEventHandler, //init page or app function PeripheralsHandler, Bit(Perip_RtcMin)|Bit(Perip_LcdOff)|Bit(Perip_LcdOn)|Bit(Perip_UartInput)| Bit(Perip_Timer)|Bit(Perip_RtcAlarm)|Bit(Perip_KeyPress)|Bit(Perip_KeyRelease), ButtonHandler, //touch input event handler function NULL, NumCtrlObjHandler, StrCtrlObjHandler, }; static const char Week[][4]={"一","二","三","四","五","六","天"}; static void DispTime(void) { RTC_TIME Time; char TimeMsg[64]; GUI_REGION DrawRegion; if(Gui_GetBgLightVal()==0) return;//背光没亮,无需更新
void out_board(){ int i, j, index, type; if( TURN ) { out("[ %d 手目 後手 ]\n", N_PLY +1 ); } else { out("[ %d 手目 先手 ]\n", N_PLY +1 ); } out(" 後手持駒= "); for( i=0; i < 8; i++) { if( B_HAND(i) > 0 ) out(" %s%d", ch_piece[i], B_HAND(i) ); } out("\n"); out(" 5 4 3 2 1\n"); for( i=0; i<5; i++ ) { out(" ---------------------\n"); out(" |"); for( j=0; j<5; j++ ) { index = i*5 + j; if( Occupied0 & Bit( index ) ) { if( (type = get_piece_on_sq_w( index )) != no_piece ) out("%s|", ch_piece2[ type ] ); else if( (type = get_piece_on_sq_b( index )) != no_piece ) out("%s|", ch_piece2[ type ] ); } else { out(" |"); continue; } } switch(i) { case 0: out(" 一\n"); break; case 1: out(" 二\n"); break; case 2: out(" 三\n"); break; case 3: out(" 四\n"); break; case 4: out(" 五\n"); break; } } out(" ---------------------\n"); out(" 先手持駒= "); for( i=0; i < 8; i++) { if( W_HAND(i) > 0 ) out(" %s%d", ch_piece[i], W_HAND(i) ); } out("\n\n"); return; }