void EggAvatar::DrawSegment(IFTImage* pImage, int firstPoint, int secondPoint, UINT32 color) { float x1 = m_FacePointXYZ[firstPoint][0]; float y1 = m_FacePointXYZ[firstPoint][1]; float z1 = m_FacePointXYZ[firstPoint][2]; float x2 = m_FacePointXYZ[secondPoint][0]; float y2 = m_FacePointXYZ[secondPoint][1]; float z2 = m_FacePointXYZ[secondPoint][2]; if (z1 < 0) { if (z2 > 0) { float r = z2/(z2-z1); x1 = x2 - r*(x2-x1); y1 = y2 - r*(y2-y1); } else { // Segment is completely hidden return; } } else if (z2 < 0) { if (z1 > 0) { float r = z1/(z2-z1); x2 = x1 + r*(x1-x2); y2 = y1 + r*(y1-y2); } else { // Segment is completely hidden return; } } POINT start = {INT(x1), INT(y1)}, end = {INT(x2), INT(y2)}; pImage->DrawLine(start, end, color, 1); }
DisplayError DisplayHDMI::Init() { lock_guard<recursive_mutex> obj(recursive_mutex_); DisplayError error = HWInterface::Create(kHDMI, hw_info_intf_, buffer_sync_handler_, &hw_intf_); if (error != kErrorNone) { return error; } uint32_t active_mode_index; char value[64] = "0"; Debug::GetProperty("sdm.hdmi.s3d_mode", value); HWS3DMode mode = (HWS3DMode)atoi(value); if (mode > kS3DModeNone && mode < kS3DModeMax) { active_mode_index = GetBestConfig(mode); } else { active_mode_index = GetBestConfig(kS3DModeNone); } error = hw_intf_->SetDisplayAttributes(active_mode_index); if (error != kErrorNone) { HWInterface::Destroy(hw_intf_); } error = DisplayBase::Init(); if (error != kErrorNone) { HWInterface::Destroy(hw_intf_); return error; } GetScanSupport(); underscan_supported_ = (scan_support_ == kScanAlwaysUnderscanned) || (scan_support_ == kScanBoth); s3d_format_to_mode_.insert(std::pair<LayerBufferS3DFormat, HWS3DMode> (kS3dFormatNone, kS3DModeNone)); s3d_format_to_mode_.insert(std::pair<LayerBufferS3DFormat, HWS3DMode> (kS3dFormatLeftRight, kS3DModeLR)); s3d_format_to_mode_.insert(std::pair<LayerBufferS3DFormat, HWS3DMode> (kS3dFormatRightLeft, kS3DModeRL)); s3d_format_to_mode_.insert(std::pair<LayerBufferS3DFormat, HWS3DMode> (kS3dFormatTopBottom, kS3DModeTB)); s3d_format_to_mode_.insert(std::pair<LayerBufferS3DFormat, HWS3DMode> (kS3dFormatFramePacking, kS3DModeFP)); error = HWEventsInterface::Create(INT(display_type_), this, event_list_, &hw_events_intf_); if (error != kErrorNone) { DisplayBase::Deinit(); HWInterface::Destroy(hw_intf_); DLOGE("Failed to create hardware events interface. Error = %d", error); } return error; }
/*********************************************************************** * Returns 1-based block number for line number (i.e. first = 1) * Lines assumed 1-based (i.e. first = 1); */ int BlockForFiltLineI(FILTER *filtPO, int line) { int block; if( line <= filtPO->l_bof ) { block = 0; } else { block = 1 + INT((line - 1 - filtPO->l_bof) / filtPO->l_blk); } return(block); }
SEXP R_PDCLVAR(SEXP X, SEXP DESCX, SEXP LSD) { R_INIT; SEXP VAR; newRvec(VAR, INT(LSD, 0), "dbl"); pdclvar_(REAL(X), INTEGER(DESCX), REAL(VAR)); R_END; return VAR; }
REAL cIncEnsembleCamera::ScoreCurGen(bool WithFaux,bool CumulDeriv) { SetOpt(); REAL mMoyResidu = 0.0; REAL mNbPts = 0.0; for ( std::list<cIncSetLiaison *>::iterator anIt = mListSl->begin(); anIt != mListSl->end(); anIt ++ ) { cIncCpleCamera * aCple = (*anIt)->Cple(); ElPackHomologue & aPack = (*anIt)->Pack(); for ( ElPackHomologue::iterator itHoms = aPack.begin(); itHoms != aPack.end(); itHoms++ ) { Pt2dr aP1 = itHoms->P1(); Pt2dr aP2 = itHoms->P2(); REAL aPds = itHoms->Pds(); REAL Residu = CumulDeriv ? aCple->DevL1AddEqCoPlan(aP1,aP2,aPds,*mSys): aCple->ValEqCoPlan(aP1,aP2); mMoyResidu += ElSquare(Residu )* aPds; mNbPts += aPds; } } if (WithFaux) { for (INT aK = 0 ; aK<INT(mFoncsAux.size()) ; aK++) { cFonctrPond aFP = mFoncsAux[aK]; if (CumulDeriv) StdAddEq(aFP.mFctr,aFP.mPds); else aFP.mFctr->ComputeValAndSetIVC(); mMoyResidu += ElSquare(aFP.mFctr->Val(0)) * aFP.mPds; mNbPts += aFP.mPds; } } return mMoyResidu / mNbPts; }
void cElHJaFacette::AddDessouSansDessus(std::vector<cElHJaFacette *> & aTabF) { for (INT aK=0 ; aK<INT(mVFRecouvrt.size()) ; aK++) { if ( mThisIsEnDessus[aK]) { mVFRecouvrt[aK]->mNbThisIsEnDessous--; if (mVFRecouvrt[aK]->mNbThisIsEnDessous==0) aTabF.push_back(mVFRecouvrt[aK]); } } }
SEXP Rth_get_num_threads() { char *rth_nthreads = getenv("RTH_NUM_THREADS"); char *omp_nthreads = getenv("OMP_NUM_THREADS"); SEXP nthreads; PROTECT(nthreads = allocVector(INTSXP, 1)); #if RTH_OMP if (rth_nthreads != NULL) INT(nthreads) = atoi(rth_nthreads); else if (omp_nthreads != NULL) INT(nthreads) = atoi(omp_nthreads); else INT(nthreads) = omp_get_max_threads(); // omp_get_max_threads #elif RTH_TBB if (rth_nthreads != NULL) INT(nthreads) = atoi(rth_nthreads); else INT(nthreads) = tbb::task_scheduler_init::automatic; #else INT(nthreads) = RTH_ERROR; #endif UNPROTECT(1); return nthreads; }
/* LU factorization */ SEXP R_PDGETRF(SEXP M, SEXP N, SEXP A, SEXP CLDIM, SEXP DESCA, SEXP LIPIV) { R_INIT; int *ipiv; int IJ = 1; SEXP RET, RET_NAMES, INFO, C; newRvec(INFO, 1, "int"); newRmat(C, INT(CLDIM, 0), INT(CLDIM, 1), "dbl"); // A = LU memcpy(DBLP(C), DBLP(A), nrows(A)*ncols(A)*sizeof(double)); INT(INFO, 0) = 0; INT(LIPIV) = nonzero(INT(LIPIV)); ipiv = (int*) R_alloc(INT(LIPIV), sizeof(int)); pdgetrf_(INTP(M), INTP(N), DBLP(C), &IJ, &IJ, INTP(DESCA), ipiv, INTP(INFO)); // Manage return RET_NAMES = make_list_names(2, "info", "A"); RET = make_list(RET_NAMES, 2, INFO, C); R_END; return RET; }
static obj_ptr _sub(obj_ptr args, obj_ptr env) { obj_ptr res = MKINT(0); int ct = 0; for (; CONSP(args); args = CDR(args)) { obj_ptr arg = CAR(args); ct++; if (NINTP(arg) && NFLOATP(arg)) { res = MKERROR(MKSTRING("Expected a number in -"), arg); return res; } else if (ct == 1) { if (INTP(arg)) INT(res) = INT(arg); else { res->type = TYPE_FLOAT; FLOAT(res) = FLOAT(arg); } } else if (INTP(arg)) { if (FLOATP(res)) FLOAT(res) -= (double)INT(arg); else INT(res) -= INT(arg); } else if (FLOATP(arg)) { if (INTP(res)) { int n = INT(res); res->type = TYPE_FLOAT; FLOAT(res) = (double)n; } FLOAT(res) -= FLOAT(arg); } } if (ct == 1) { if (INTP(res)) INT(res) *= -1; else FLOAT(res) *= -1; } return res; }
int OCCEdge::createSpline(OCCVertex *start, OCCVertex *end, std::vector<OCCStruct3d> points, double tolerance) { try { Standard_Boolean periodic = false; Standard_Real tol = tolerance; int vertices = 0; if (start != NULL && end != NULL) { vertices = 2; } int nbControlPoints = points.size(); Handle(TColgp_HArray1OfPnt) ctrlPoints; ctrlPoints = new TColgp_HArray1OfPnt(1, nbControlPoints + vertices); int index = 1; if (vertices) { ctrlPoints->SetValue(index++, gp_Pnt(start->X(), start->Y(), start->Z())); } for (int i = 0; i < nbControlPoints; i++) { gp_Pnt aP(points[i].x,points[i].y,points[i].z); ctrlPoints->SetValue(index++, aP); } if (vertices) { ctrlPoints->SetValue(index++, gp_Pnt(end->X(), end->Y(), end->Z())); } GeomAPI_Interpolate INT(ctrlPoints, periodic, tol); INT.Perform(); Handle(Geom_BSplineCurve) curve = INT.Curve(); if (vertices) { this->setShape(BRepBuilderAPI_MakeEdge(curve, start->vertex, end->vertex)); } else { this->setShape(BRepBuilderAPI_MakeEdge(curve)); } } catch(Standard_Failure &err) { Handle_Standard_Failure e = Standard_Failure::Caught(); const Standard_CString msg = e->GetMessageString(); if (msg != NULL && strlen(msg) > 1) { setErrorMessage(msg); } else { setErrorMessage("Failed to create spline"); } return 0; } return 1; }
//----------------------------------------------------------------------------- // Name: XBUtil_GetWide() // Desc: Convert CHAR string to WCHAR string. dwMax includes the null byte. // Never copies more than dwMax-1 characters into strWide. // Ex: GetWide( "abc", strWide, 3 ) gives strWide = "ab" // Typical usage: // WCHAR strResult[MAX]; // XBUtil_GetWide( strThin, strResult, MAX ); //----------------------------------------------------------------------------- VOID XBUtil_GetWide( const CHAR* strThin, WCHAR* strWide, DWORD dwMax ) { assert( strThin != NULL ); assert( strWide != NULL ); // dwMax includes the null bytes, so must always be at least one. // Furthermore, if dwMax is 0, MultiByteToWideChar doesn't do any // conversion, but returns the number of chars it *would* convert. assert( dwMax > 0 ); // Determine how many characters we will convert. Can never be more // than dwMax-1 INT nChars = lstrlenA( strThin ); if( nChars > INT(dwMax) - 1 ) nChars = INT(dwMax) - 1; // Perform the conversion INT iWide = MultiByteToWideChar( CP_ACP, 0, strThin, nChars, strWide, dwMax ); assert( nChars == iWide - 1 ); (VOID)iWide; // avoid compiler warning in release mode }
void CUserProgressDlg::SetProgress(FLOAT value) { ASSERT(value >= 0.0f && value <= 1.0f); if (m_progressValue != value) { m_progressValue = value; if (m_progress.m_hWnd != NULL) { m_progress.SetPos(INT(value * 1000)); m_progress.Invalidate(); } } }
STATIC NOINLINE INT MyMessageBox(HWND hWnd, LPTSTR lpMessage, LPTSTR lpCaption, UINT uFlags) { STATIC INT(WINAPI* pfnMessageBox)(HWND, LPTSTR, LPTSTR, UINT) = NULL; if(pfnMessageBox == NULL) { // Load user32.dll HMODULE hUser32 = LoadLibraryW(L"user32.dll"); assert(hUser32 != NULL); // Grab our MessageBox function *((FARPROC*)(&pfnMessageBox)) = GetProcAddress(hUser32, XSTRA(MessageBox)); assert(pfnMessageBox != NULL); } // Show message box return pfnMessageBox(hWnd, lpMessage, lpCaption, uFlags); }
/* find the matching closed brace. */ SEXP match_brace(SEXP lines, SEXP start, SEXP open_brace, SEXP close_brace) { int depth = 0, open = 0, line_id = INT(start) - 1; const char *current = NULL; const char *op = CHAR(STRING_ELT(open_brace, 0)); const char *cl = CHAR(STRING_ELT(close_brace, 0)); SEXP stop; do { /* dereference the current line. */ current = CHAR(STRING_ELT(lines, line_id)); /* increment the depth counter if an open brace is found. */ if (strstr(current, op)) { /* be sure no to exit from the do-while loop until an open curly brace * has been spotted. */ open = 1; depth++; }/*THEN*/ /* decrement the depth counter if a closed brace is found. */ if (strstr(current, cl)) depth--; /* increment the line id. */ line_id++; } while ((depth > 0) || (open == 0)); /* allocate and assing the return value. */ PROTECT(stop = allocVector(INTSXP, 1)); INT(stop) = line_id; UNPROTECT(1); return stop; }/*MATCH_BRACE*/
void Metabolize (const Protein &p) { INFORM (p); INFORM ("image-request protein received, responding..."); ImageData *tex = FetchImageData ("images/" + INT ((page++) % 6 + 1) + ".jpg"); if (tex) { Protein response = ProteinWithDescrip ("image-result"); AppendIngest (response, "image-texture", tex); Deposit (response, poolname); } else WARN ("Couldn't send response because we failed to load an image."); }
static obj_ptr _div(obj_ptr args, obj_ptr env) { obj_ptr res = MKFLOAT(0); int ct = 0; for (; CONSP(args); args = CDR(args)) { obj_ptr arg = CAR(args); ct++; if (NINTP(arg) && NFLOATP(arg)) { res = MKERROR(MKSTRING("Expected a number in /"), arg); return res; } else if (ct == 1) { if (INTP(arg)) FLOAT(res) = (double)INT(arg); else FLOAT(res) = FLOAT(arg); } else if (INTP(arg)) { FLOAT(res) /= (double)INT(arg); } else if (FLOATP(arg)) { FLOAT(res) /= FLOAT(arg); } } if (ct == 1) { FLOAT(res) = 1 / FLOAT(res); } return res; }
INT ComputeLongSteps(DXVA2_ValueRange &range) { float f_step = DXVA2FixedToFloat(range.StepSize); if (f_step == 0.0) return 0; float f_max = DXVA2FixedToFloat(range.MaxValue); float f_min = DXVA2FixedToFloat(range.MinValue); INT steps = INT((f_max - f_min) / f_step / 32); return max(steps, 1); }
VOID hgeAnimation::SetFrame(INT n) { FLOAT tx1, ty1, tx2, ty2; BOOL bX, bY, bHS; INT ncols = INT(orig_width) / INT(width); n = n % nFrames; if(n < 0) n = nFrames + n; nCurFrame = n; // calculate texture coords for frame n ty1 = ty; tx1 = tx + n*width; if(tx1 > orig_width-width) { n -= INT(orig_width-tx) / INT(width); tx1 = width * (n%ncols); ty1 += height * (1 + n/ncols); } tx2 = tx1 + width; ty2 = ty1 + height; tx1 /= tex_width; ty1 /= tex_height; tx2 /= tex_width; ty2 /= tex_height; quad.v[0].tx=tx1; quad.v[0].ty=ty1; quad.v[1].tx=tx2; quad.v[1].ty=ty1; quad.v[2].tx=tx2; quad.v[2].ty=ty2; quad.v[3].tx=tx1; quad.v[3].ty=ty2; bX=bXFlip; bY=bYFlip; bHS=bHSFlip; bXFlip=FALSE; bYFlip=FALSE; SetFlip(bX,bY,bHS); }
/* Solving systems of linear equations */ SEXP R_PDGESV(SEXP N, SEXP NRHS, SEXP MXLDIMS, SEXP A, SEXP DESCA, SEXP B, SEXP DESCB) { R_INIT; int IJ = 1; int * ipiv; double *A_cp; SEXP RET, RET_NAMES, INFO, B_OUT; newRvec(INFO, 1, "int"); newRmat(B_OUT, nrows(B), ncols(B), "dbl"); // Copy A and B since pdgesv writes in place A_cp = (double *) R_alloc(nrows(A)*ncols(A), sizeof(double)); //FIXME check returns... memcpy(A_cp, DBLP(A), nrows(A)*ncols(A)*sizeof(double)); memcpy(DBLP(B_OUT), DBLP(B), nrows(B)*ncols(B)*sizeof(double)); // Call pdgesv ipiv = (int *) R_alloc(INT(MXLDIMS, 0) + INT(DESCA, 5), sizeof(int)); /* ipiv = (int *) R_alloc(nrows(B) + INT(DESCA, 5), sizeof(int));*/ INT(INFO, 0) = 0; pdgesv_(INTP(N), INTP(NRHS), A_cp, &IJ, &IJ, INTP(DESCA), ipiv, DBLP(B_OUT), &IJ, &IJ, INTP(DESCB), INTP(INFO)); // Manage return RET_NAMES = make_list_names(2, "info", "B"); RET = make_list(RET_NAMES, 2, INFO, B_OUT); R_END; return RET; }
VALUE kernel_sleep(VALUE self, VALUE arg) { int secs; if (TYPE(arg) != T_INTEGER) arg = funcall(arg, "to_i", 0); secs = INT(arg)->num; while (secs > 0) secs = sleep(secs); return Qnil; }
INT MessageLoop(HWND hwnd) { MSG msg = {0}; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } DestroyWindow(hwnd); return INT(msg.wParam); }
void approx_poly ( ElFifo<INT> & res, const ElFifo<Pt2di> & fpi, ArgAPP arg ) { ElFifo<Pt2dr> fpr(fpi.size(),fpi.circ());; for (INT aK=0 ; aK<INT(fpi.size()) ; aK++) fpr.push_back(Pt2dr(fpi[aK])); approx_poly(res,fpr,arg); }
/* -------------------------------------------------------------------------- */ HCTX static NEAR TabletInit(HWND hWnd, FIX32 scale[]) { LOGCONTEXT lcMine; /* get default region */ WTInfo(WTI_DEFCONTEXT, 0, &lcMine); /* modify the digitizing region */ strcpy(lcMine.lcName, "Rule Digitizing"); lcMine.lcPktData = PACKETDATA; lcMine.lcPktMode = PACKETMODE; lcMine.lcMoveMask = 0; lcMine.lcBtnUpMask = lcMine.lcBtnDnMask; /* output in 1000ths of cm */ lcMine.lcOutOrgX = lcMine.lcOutOrgY = 0; lcMine.lcOutExtX = INT(scale[0] * lcMine.lcInExtX); lcMine.lcOutExtY = INT(scale[1] * lcMine.lcInExtY); /* open the region */ return WTOpen(hWnd, &lcMine, TRUE); }
void main (void) { filename=parse_args (); puts ("PCX Viewer v1.0"); puts ("by Ricardo Bittencourt"); putchar (10); file=open (filename); header=(char *) malloc (128); read (file,header); print ("Name: "); puts (filename); print ("Xmax: "); number (INT (header,8),10); putchar (13); putchar (10); print ("Ymax: "); number (INT (header,10),10); putchar (13); putchar (10); putchar (10); print ("Press any key to start..."); getchar (); screen (8); read_pcx (file,header); getchar (); screen (0); }
int main() { std::cout << "This is the type test" << std::endl; INT a = INT(3); // TODO: More effective ways of new an INT. INT b = INT(1); INT c = INT(5); std::cout << "[ostream test] A shoud be 3, actually is: " << a << std::endl; std::cout << "[addition test] Sum should be 6, actually is: " << b + c << std::endl; assert(b + c == 6); std::cout << "[subtraction test] Sum should be -2, actually is: " << a - c << std::endl; assert(a - c == -2); std::cout << "[multiplication test] Sum should be 3, actually is: " << b * a << std::endl; assert(b * a == 3); std::cout << "[division test] Sum should be 1, actually is: " << c / a << std::endl; assert(c / a == 1); std::cout << "[remainder test] Sum should be 2, actually is: " << c % a << std::endl; assert(c % a == 2); std::cout << "[power test] Sum should be 125, actually is: " << (c^a) << std::endl; // Priority problems? assert((c ^ a) == 125); // TODO: Rewrite in <cassert>. // std::cout << "[ test] Sum should be 6, actually is: " << b + c << std::endl; }
static inline void cairo_DrawLine(struct qp_graph *gr, int *new_line, double from_x, double from_y, double to_x, double to_y) { /* Tests show that defining this EXTRA_CULL makes * drawing a little faster when there are greater * than 1,000,000 points. But this speed * increase is not significant. Just like 0.25 * seconds out of 4 seconds. We think simple is * better. It appears that the cairo line drawing * is already doing something to give good results. */ //#define EXTRA_CULL #ifdef EXTRA_CULL /* yes this is not thread safe */ static int prev_to_x = INT_MAX, prev_to_y = INT_MAX; int x, y; #endif /* If numbers of out of range we need to know. If the line width * is too large this will not work. */ ASSERT(to_x > -50. && to_x < 3.0*app->root_window_width + 50); ASSERT(from_x > -50. && from_x < 3.0*app->root_window_width + 50); ASSERT(to_y > -50. && to_y < 3.0*app->root_window_height + 50); ASSERT(from_y > -50. && from_y < 3.0*app->root_window_height + 50); if(*new_line) { /* Tests show that casting to int makes drawing faster in cairo */ cairo_move_to(gr->cr, INT(from_x), INT(from_y)); #ifdef EXTRA_CULL /* reset the prev_to values */ prev_to_x = INT_MAX; prev_to_y = INT_MAX; #endif } #ifdef EXTRA_CULL x = INT(to_x); y = INT(to_y); /* Do not draw if we are drawing to the same point again. * This is slower for small data files, but a big gain * in speed for large data files. */ if(prev_to_x != x || prev_to_y != y) cairo_line_to(gr->cr, x, y); prev_to_x = x; prev_to_y = y; #else cairo_line_to(gr->cr, INT(to_x), INT(to_y)); #endif *new_line = 0; }
void read_pcx (int file, char *header) { xmax=INT (header,8); ymax=INT (header,10); nplanes=header[65]; bytesperline=INT (header,66); bufferr=(char *) malloc (bytesperline); bufferg=(char *) malloc (bytesperline); bufferb=(char *) malloc (bytesperline); prepare (); for (j=0; j<=ymax; j++) { for (k=0; k<nplanes; k++) { if (k==0) pb=bufferr; if (k==1) pb=bufferg; if (k==2) pb=bufferb; for (i=0; i<bytesperline;) { d=fetch (file); if (d>0xc0) { d2=fetch (file); for (l=0; l<d-0xc0; l++) { *pb++=d2; i++; } } if (0xc0>d) { *pb++=d; i++; } } } pbufr=bufferr; pbufg=bufferg; pbufb=bufferb; for (i=0; i<=xmax; i++) { vpoke ((j<<8)+i,uniformRGB (*pbufr++,*pbufg++,*pbufb++)); } } }
/************************************************************************* * Check options and allocate / set mask if needed */ int HandleFilterMaskingI(FILTER *filtPO) { int block; DOUB fracD; if( NeedFilterMaskingI(filtPO) ) { if( IsFileStdinI(filtPO->in) ) { PROBLINE; printf("Options not compatible with stdin\n\n"); return(FALSE); } /*** * Last two args mean ignore comments and blanks * Then rewind file and allocate space for line mask */ filtPO->n_mask = FileLinesI(filtPO->in,TRUE,TRUE); filtPO->n_block = INT((filtPO->n_mask - filtPO->l_bof) / filtPO->l_blk); rewind(filtPO->in); filtPO->mask = (char *)ALLOC(filtPO->n_mask, sizeof(char)); if(!filtPO->mask) { PROBLINE; printf("Can't allocate mask for %d input lines\n",filtPO->n_mask); return(FALSE); } /*** * If doing random fraction, calc frac and set */ fracD = -1.0; if( filtPO->rann > 0) { if( filtPO->l_blk > 1) { block = BlockForFiltLineI(filtPO, filtPO->n_mask); fracD = RNUM(filtPO->rann) / RNUM(block); } else { fracD = RNUM(filtPO->rann) / RNUM(filtPO->n_mask); } } else if( filtPO->ranf >= 0.0) { fracD = filtPO->ranf; } if(fracD >= 0.0) { SetRandFilterMaskingI(filtPO, fracD); } /* DumpArray(filtPO->mask, IS_CHAR, 0, filtPO->n_mask, " M=%d\n", NULL); */ } return(TRUE); }
// next best divisor function SEXP R_nbd(SEXP N, SEXP D) { R_INIT; int i, test; const int n = INT(N); const int d = INT(D); SEXP RET; newRvec(RET, 1, "int"); INT(RET) = d; for (i=INT(RET, 0); i<=n; i++) { test = n % i; if (test == 0){ INT(RET) = i; break; } } R_END; return RET; }
INT CALLBACK CBreedDlg::SortPokemons(LPARAM lParam1, LPARAM lParam2, LPARAM lSortParam) { INT iResult = 0; if(rom.m_bOpened) { switch(lSortParam) { case pm_order_internal: iResult = INT(lParam1 - lParam2); break; case pm_order_kanto: iResult = INT(rom.m_pPokedexKantoOrder[lParam1] - rom.m_pPokedexKantoOrder[lParam2]); break; case pm_order_houen: iResult = INT(rom.m_pPokedexHouenOrder[lParam1] - rom.m_pPokedexHouenOrder[lParam2]); break; } } return iResult; }