/* tej - changed return type to void as nothing returned */ void InitMFS(void) { char far *LOL; char far *SDA; struct REGPACK preg; LOL = GetListOfLists(); SDA = GetSDAPointer(); /* get DOS version into CX */ preg.r_cx = _osmajor | (_osminor <<8); preg.r_dx = FP_OFF(LOL); preg.r_es = FP_SEG(LOL); preg.r_si = FP_OFF(SDA); preg.r_ds = FP_SEG(SDA); preg.r_bx = 0x500; preg.r_ax = 0x20; intr(DOS_HELPER_INT, &preg); }
static int find95(char *name, FF_Block95 *ff, int attr) { struct REGPACK r; r.r_ax = 0x714e; r.r_cx = attr; r.r_si = 1; /* MS-DOS style time */ r.r_ds = FP_SEG(name); r.r_dx = FP_OFF(name); r.r_es = FP_SEG(&ff->ff_95); r.r_di = FP_OFF(&ff->ff_95); r.r_flags = 0; intr(0x21, &r); if(r.r_flags & 1) { /* Failure */ ff->ff_95.ff_status = NOFIND95; return r.r_ax; } ff->ff_95.ff_status = r.r_ax; conv95(ff); return 0; /* OK */ }
/* ------------------------------------------------------------------------ */ int FindNext(find_data* FindData) { FindData->Filename[0] = END_OF_STRING; if (FindData->UseLFN) { struct REGPACK r; lfn_find_results FindResults; r.r_ax = 0x714F; /* Find next matching file */ r.r_bx = FindData->Handle; r.r_si = 1; /* MS-DOS style time */ r.r_es = FP_SEG(&FindResults); r.r_di = FP_OFF(&FindResults); r.r_flags = CARRY; /* Set carry to prepare for failure */ intr(DOS, &r); if ((r.r_flags & CARRY) == 0) /* No carry -> Ok */ { errno = 0; if (FindResults.LongFilename != END_OF_STRING) strncpy(FindData->Filename, FindResults.LongFilename, sizeof(FindData->Filename) - 1); else strncpy(FindData->Filename, FindResults.ShortFilename, sizeof(FindData->Filename) - 1); FindData->Attributes = FindResults.Attributes & 0xFF; } else errno = r.r_ax; /* DOS error code */ } else { errno = findnext(&(FindData->SearchRec)); if (errno == 0) { strncpy(FindData->Filename, FindData->SearchRec.ff_name, sizeof(FindData->Filename) - 1); FindData->Attributes = FindData->SearchRec.ff_attrib; } } return errno; }
void interpret_packet(void) { int size = rx(); // ignore. protocol is self-terminating. (void)size; int command = rx(); switch(command & 0x0F) { default: case 0: ack(); break; case 1: npush(); break; case 2: npop(); break; case 3: jsr(); break; case 4: lda(); break; case 5: ldf(); break; case 7: intr(); break; case 8: nafetch(); break; case 9: nffetch(); break; case 10: nastore(); break; case 11: nfstore(); break; } infof("\n"); }
void ShowMouse(void) { char fikt1, fikt2; int mousex, mousey; GetMouseButtons(&fikt1, &fikt2, &mousex, &mousey); cursorx = mousex; cursory = mousey; // and now draw to the new cursor place ... setwritemode(XOR_PUT); BLine(cursorx, cursory - 2, cursorx, cursory - 10, C); BLine(cursorx, cursory + 2, cursorx, cursory + 10, C); BLine(cursorx - 2, cursory, cursorx - 10, cursory, C); BLine(cursorx + 2, cursory, cursorx + 10, cursory, C); // istalling again the mouse event handler ... registers.r_ax = 0x0c; registers.r_cx = 0x01; registers.r_es = FP_SEG(mouse_event_handler); registers.r_dx = FP_OFF(mouse_event_handler); intr(0x33, ®isters); }
/* Message disaptcher - executed on i860 thread, safe to call i860 methods */ bool i860_cpu_device::handle_msgs() { host_lock(&m_port_lock); int msg = m_port; m_port = 0; host_unlock(&m_port_lock); if(ConfigureParams.Dimension.bI860Thread && msg & MSG_I860_KILL) return false; if(msg & MSG_I860_RESET) reset(); else if(msg & MSG_INTR) intr(); if(msg & MSG_DISPLAY_BLANK) nd_set_blank_state(ND_DISPLAY, host_blank_state(ND_SLOT, ND_DISPLAY)); if(msg & MSG_VIDEO_BLANK) nd_set_blank_state(ND_VIDEO, host_blank_state(ND_SLOT, ND_VIDEO)); if(msg & MSG_DBG_BREAK) debugger('d', "BREAK at pc=%08X", m_pc); return true; }
void reset_x86(void) { // From [The easiest way to reset i386/x86_64 system] // (http://www.pagetable.com/?p=140). The original code // caused an GP fault (exception 13), but this code // works. IdtPtr null_idtr; null_idtr.limit = 0; null_idtr.iig = 0; cli(); set_idt(&null_idtr); intr(3); // Loop with interrupts off if it doesn't work while (1) { hlt(); } }
bool IntrSegment2Triangle2<Real>::Test () { Real dist[3]; int sign[3], positive, negative, zero; IntrLine2Triangle2<Real>::TriangleLineRelations(mSegment->Center, mSegment->Direction, *mTriangle, dist, sign, positive, negative, zero); if (positive == 3 || negative == 3) { mIntersectionType = IT_EMPTY; } else { Real param[2]; IntrLine2Triangle2<Real>::GetInterval(mSegment->Center, mSegment->Direction, *mTriangle, dist, sign, param); Intersector1<Real> intr(param[0], param[1], -mSegment->Extent, +mSegment->Extent); intr.Find(); mQuantity = intr.GetNumIntersections(); if (mQuantity == 2) { mIntersectionType = IT_SEGMENT; } else if (mQuantity == 1) { mIntersectionType = IT_POINT; } else { mIntersectionType = IT_EMPTY; } } return mIntersectionType != IT_EMPTY; }
bool IntrCircle3Plane3<Real>::Test () { mQuantity = 0; // Construct the plane of the circle. Plane3<Real> CPlane(mCircle->Normal,mCircle->Center); // Compute the intersection of this plane with the input plane. IntrPlane3Plane3<Real> intr(*mPlane,CPlane); if (!intr.Find()) { // Planes are parallel and nonintersecting. mIntersectionType = IT_EMPTY; return false; } if (intr.GetIntersectionType() == IT_PLANE) { // Planes are the same, the circle is the common intersection set. mIntersectionType = IT_OTHER; return true; } // The planes intersect in a line. const Line3<Real>& line = intr.GetIntersectionLine(); // Locate one or two points that are on the circle and line. If the // line is t*D+P, the circle center is C, and the circle radius is r, // then r^2 = |t*D+P-C|^2 = |D|^2*t^2 + 2*Dot(D,P-C)*t + |P-C|^2. This // is a quadratic equation of the form: a2*t^2 + 2*a1*t + a0 = 0. Vector3<Real> diff = line.Origin - mCircle->Center; Real a2 = line.Direction.SquaredLength(); Real a1 = diff.Dot(line.Direction); Real a0 = diff.SquaredLength() - mCircle->Radius*mCircle->Radius; // Real-valued roots imply an intersection. Real discr = a1*a1 - a0*a2; mIntersectionType = (discr >= (Real)0 ? IT_POINT : IT_EMPTY); return mIntersectionType != IT_EMPTY; }
bool IntrLine2Triangle2<Real>::Test () { Real dist[3]; int sign[3], positive, negative, zero; TriangleLineRelations(mLine->Origin, mLine->Direction, *mTriangle, dist, sign, positive, negative, zero); if (positive == 3 || negative == 3) { mIntersectionType = IT_EMPTY; } else { Real param[2]; GetInterval(mLine->Origin, mLine->Direction, *mTriangle, dist, sign, param); Intersector1<Real> intr(param[0], param[1], -Math<Real>::MAX_REAL, +Math<Real>::MAX_REAL); intr.Find(); mQuantity = intr.GetNumIntersections(); if (mQuantity == 2) { mIntersectionType = IT_SEGMENT; } else if (mQuantity == 1) { mIntersectionType = IT_POINT; } else { mIntersectionType = IT_EMPTY; } } return mIntersectionType != IT_EMPTY; }
/* * send_stuff: * Send standard input characters to the driver */ static void send_stuff() { int count; char *sp, *nsp; static char inp[sizeof Buf]; count = read(STDIN, Buf, sizeof Buf); if (count <= 0) return; if (nchar_send <= 0 && !no_beep) { (void) write(1, "\7", 1); /* CTRL('G') */ return; } /* * look for 'q'uit commands; if we find one, * confirm it. If it is not confirmed, strip * it out of the input */ Buf[count] = '\0'; nsp = inp; for (sp = Buf; *sp != '\0'; sp++) if ((*nsp = map_key[(int)*sp]) == 'q') intr(0); else nsp++; count = nsp - inp; if (count) { # ifdef OTTO Otto_count += count; # endif nchar_send -= count; if (nchar_send < 0) count += nchar_send; (void) write(Socket, inp, count); } }
/******************************************** * GetRedirection - get next entry from list of redirected devices * ON ENTRY: * redirIndex has the index of the next device to return * this should start at 0, and be incremented between calls * to retrieve all elements of the redirection list * ON EXIT: * returns CC_SUCCESS if the operation was successful, and * deviceStr has a string with the device name: * either disk or printer (ex. 'D:' or 'LPT1') * resourceStr has a string with the server and name of resource * (ex. 'TIM\TOOLS') * deviceType indicates the type of device which was redirected * 3 = printer, 4 = disk * deviceParameter has my rights to this resource * NOTES: * ********************************************/ static uint16 GetRedirection(uint16 redirIndex, char *deviceStr, char **presourceStr, uint8 * deviceType, uint16 * deviceParameter) { uint16 ccode; uint8 deviceTypeTemp; char slashedResourceStr[MAX_RESOURCE_PATH_LENGTH]; struct REGPACK preg = REGPACK_INIT; char *dStr, *sStr; dStr = lowmem_alloc(16); preg.r_ds = FP_SEG(dStr); preg.r_si = FP_OFF(dStr); sStr = lowmem_alloc(128); preg.r_es = FP_SEG(sStr); preg.r_di = FP_OFF(sStr); preg.r_bx = redirIndex; preg.r_ax = DOS_GET_REDIRECTION; intr(0x21, &preg); strcpy(deviceStr,dStr); lowmem_free(dStr, 16); strcpy(slashedResourceStr,sStr); lowmem_free(sStr, 128); ccode = preg.r_ax; deviceTypeTemp = preg.r_bx & 0xff; /* save device type before C ruins it */ *deviceType = deviceTypeTemp; *deviceParameter = preg.r_cx; /* copy back unslashed portion of resource string */ if (preg.r_flags & CARRY_FLAG) { return (ccode); } else { /* eat the leading slashes */ *presourceStr = strdup(slashedResourceStr + 2); return (CC_SUCCESS); } }
/** * IMouseGetButtonStatus checks to see if any of the mouse buttons * are being held and returns the status of those buttons. * * @return the bit combination of the mouse * mouse buttons. * *<!-----------------------------------------------------------------------*/ static T_buttonClick IMouseGetButtonStatus(T_void) { #if DOS32 union REGPACK regs; T_word16 buttonStatus ; DebugRoutine("IMouseGetButtonStatus") ; DebugCheck(F_MouseIsInitialized == TRUE) ; /* Call the int 0x33 for the button status of the mouse. */ memset(®s,0,sizeof(union REGPACK)); regs.w.ax = 3; intr(0x33,®s); buttonStatus = regs.w.bx; DebugEnd() ; return buttonStatus ; #else extern T_buttonClick DirectMouseGetButton(T_void) ; return DirectMouseGetButton() ; #endif }
main(){ //Principal system("color A"); system("title Jogo da Velha"); developers();clrscr(); //Apresentação do trabalho intr(); //Mostra a animação int op,ani; while(1){ //Loop infinito até o jogado escolher sair vlgx=0;vlgy=0,emp=0,beginJg=0; op=menu(); // Chama a função menu que retornará a opção escolhida pelo usuário. clrscr(); if(op==0){game();} //Se opção for igual a 0 entra no jogo if(op==1){rank();} //Se opção for igual a 1 entra no ranking if(op==2){config();}//Se opção for igual a 2 entra em configuração if(op==3){ //Se opção for igual a 3 então mostra uma pequena animação e fecha o jogo. for(ani=0;ani<25;ani++){ gotoxy(35,1+ani); printf("Finish the game!");Sleep(100);clrscr();} return 0;} } system("pause>>null"); }
/** * MouseCheckInstalled checks to see if a mouse is available. If there * is one, TRUE is returned. If not, a FALSE is returned. * * @return TRUE = Mouse driver installed * FALSE= No mouse driver found * *<!-----------------------------------------------------------------------*/ E_Boolean MouseCheckInstalled(T_void) { #ifdef DOS32 E_Boolean f_installed ; union REGPACK regs; DebugRoutine("MouseCheckInstalled") ; memset(®s,0,sizeof(union REGPACK)); intr(0x33,®s); if (regs.w.ax == ((T_word16)-1)) f_installed = TRUE ; else f_installed = FALSE ; DebugCheck(f_installed < BOOLEAN_UNKNOWN) ; DebugEnd() ; return(f_installed); #else return TRUE ; #endif }
size_t farread(void far*buf, size_t length, FILE *f) { #if 0 struct REGPACK r; #endif /* synchronize FILE* with file descriptor in order to be able to call the DOS API */ lseek(fileno(f), ftell(f), SEEK_SET); /* Use DOS API in order to read the strings directly to the far address */ #if 0 r.r_ax = 0x3f00; /* read from file descriptor */ r.r_bx = fileno(f); /* file descriptor */ r.r_cx = length; /* size of block to read */ r.r_ds = FP_SEG(buf); /* segment of buffer to read block to */ r.r_dx = FP_OFF(buf); /* offset of buffer to read block to */ intr( 0x21, &r ); return( ( r.r_flags & 1 ) ? 0 : r.r_ax ); #else return( DOSreadwrite( fileno( f ), buf, length, 0x3F00 ) ); #endif }
static unsigned short dos_get_code_page( void ) /*********************************************/ { if( _IsPharLap() ) { union REGPACK regs; memset( ®s, 0, sizeof( regs ) ); regs.w.ax = 0x6601; /* get extended country info */ intr( 0x21, ®s ); if( (regs.w.flags & 1) == 0 ) { return( regs.w.bx ); /* return active code page */ } } else if( _IsRational() ) { rm_call_struct dblock; memset( &dblock, 0, sizeof( dblock ) ); dblock.eax = 0x6601; /* get extended country info */ DPMISimulateRealModeInterrupt( 0x21, 0, 0, &dblock ); if( (dblock.flags & 1) == 0 ) { return( (unsigned short)dblock.ebx ); } } return( 437 ); /* return default */ }
void ICPOdometry::getIncrementalTransformation(Eigen::Vector3f & trans, Eigen::Matrix<float, 3, 3, Eigen::RowMajor> & rot, int threads, int blocks) { iterations[0] = 10; iterations[1] = 5; iterations[2] = 4; Eigen::Matrix<float, 3, 3, Eigen::RowMajor> Rprev = rot; Eigen::Vector3f tprev = trans; Eigen::Matrix<float, 3, 3, Eigen::RowMajor> Rcurr = Rprev; Eigen::Vector3f tcurr = tprev; Eigen::Matrix<float, 3, 3, Eigen::RowMajor> Rprev_inv = Rprev.inverse(); Mat33 & device_Rprev_inv = device_cast<Mat33>(Rprev_inv); float3& device_tprev = device_cast<float3>(tprev); cv::Mat resultRt = cv::Mat::eye(4, 4, CV_64FC1); for(int i = NUM_PYRS - 1; i >= 0; i--) { for(int j = 0; j < iterations[i]; j++) { Eigen::Matrix<float, 6, 6, Eigen::RowMajor> A_icp; Eigen::Matrix<float, 6, 1> b_icp; Mat33& device_Rcurr = device_cast<Mat33> (Rcurr); float3& device_tcurr = device_cast<float3>(tcurr); DeviceArray2D<float>& vmap_curr = vmaps_curr_[i]; DeviceArray2D<float>& nmap_curr = nmaps_curr_[i]; DeviceArray2D<float>& vmap_g_prev = vmaps_g_prev_[i]; DeviceArray2D<float>& nmap_g_prev = nmaps_g_prev_[i]; float residual[2]; icpStep(device_Rcurr, device_tcurr, vmap_curr, nmap_curr, device_Rprev_inv, device_tprev, intr(i), vmap_g_prev, nmap_g_prev, distThres_, angleThres_, sumData, outData, A_icp.data(), b_icp.data(), &residual[0], threads, blocks); lastICPError = sqrt(residual[0]) / residual[1]; lastICPCount = residual[1]; Eigen::Matrix<double, 6, 1> result; Eigen::Matrix<double, 6, 6, Eigen::RowMajor> dA_icp = A_icp.cast<double>(); Eigen::Matrix<double, 6, 1> db_icp = b_icp.cast<double>(); lastA = dA_icp; lastb = db_icp; result = lastA.ldlt().solve(lastb); Eigen::Isometry3f incOdom; OdometryProvider::computeProjectiveMatrix(resultRt, result, incOdom); Eigen::Isometry3f currentT; currentT.setIdentity(); currentT.rotate(Rprev); currentT.translation() = tprev; currentT = currentT * incOdom.inverse(); tcurr = currentT.translation(); Rcurr = currentT.rotation(); } } trans = tcurr; rot = Rcurr; }
int main(int argc, char * argv[]) { try { libmaus2::util::ArgInfo const arginfo(argc,argv); // free list for alignments libmaus2::util::GrowingFreeList<libmaus2::bambam::BamAlignment> BAFL; // insert size int64_t const insertsize = arginfo.getValue<int64_t>("insertsize",800); // container for bam decoders DecoderContainer deccont; while ( std::cin ) { // eof? if ( std::cin.peek() < 0 ) break; // get next instance line InstanceLine IS(&deccont,std::cin); std::cout << IS << '\n'; uint64_t ilow = 0; while ( ilow != IS.size() ) { uint64_t ihigh = ilow; // get interval for one type of instance while ( ihigh != IS.size() && IS.instances[ihigh].type == IS.instances[ilow].type ) ++ihigh; // if type is split, improper or samestrand if ( IS.instances[ilow].type == Instance::instance_type_split || IS.instances[ilow].type == Instance::instance_type_improper || IS.instances[ilow].type == Instance::instance_type_samestrand ) { // key is maxcnt,num std::map<SubInstKey, std::vector<std::string>, std::greater<SubInstKey> > subinst; for ( uint64_t i = ilow; i < ihigh; ++i ) { std::vector<libmaus2::bambam::BamAlignment *> retlist; // map from read name to vector of alignments std::map<std::string, std::vector<libmaus2::bambam::BamAlignment *> > amap; libmaus2::bambam::BamHeader::unique_ptr_type uheader; // get alignments from A file marked with gene A { libmaus2::bambam::BamAlignmentDecoder & deca = IS.getInstanceDecoderA(i); libmaus2::bambam::BamAlignment & algna = deca.getAlignment(); libmaus2::bambam::BamHeader const & headera = deca.getHeader(); libmaus2::bambam::BamHeader::unique_ptr_type theader(headera.uclone()); uheader = UNIQUE_PTR_MOVE(theader); while ( deca.readAlignment() ) if ( algna.isMapped() && hasGeneComment(&algna,IS.geneA.name) ) { // std::cerr << algna.formatAlignment(headera) << std::endl; libmaus2::bambam::BamAlignment * palgn = BAFL.get(); retlist.push_back(palgn); amap[algna.getName()].push_back(palgn); palgn->swap(algna); } } // get alignments from B file marked with gene B { libmaus2::bambam::BamAlignmentDecoder & decb = IS.getInstanceDecoderB(i); libmaus2::bambam::BamAlignment & algnb = decb.getAlignment(); // libmaus2::bambam::BamHeader const & headerb = decb->getHeader(); while ( decb.readAlignment() ) if ( algnb.isMapped() && hasGeneComment(&algnb,IS.geneB.name) ) { // std::cerr << algna.formatAlignment(headera) << std::endl; libmaus2::bambam::BamAlignment * palgn = BAFL.get(); retlist.push_back(palgn); amap[algnb.getName()].push_back(palgn); palgn->swap(algnb); } } // pair map intervals std::vector<MappedPair> pairs; // count read pairs for gene pair uint64_t cnt = 0; // iterate over names for ( std::map<std::string, std::vector<libmaus2::bambam::BamAlignment *> >::iterator ita = amap.begin(); ita != amap.end(); ++ita ) { // get vector of alignments for name std::vector<libmaus2::bambam::BamAlignment *> & V = ita->second; // sort by (refid,pos,read1) std::sort(V.begin(),V.end(),PosComparator()); // remove multiple copies of same alignment uint64_t o = 0; uint64_t rcnt[2] = {0,0}; for ( uint64_t l = 0; l < V.size(); ) { // skip over multiple copies of same alignment uint64_t h = l; while ( h != V.size() && sameAlignment(V[l],V[h]) ) ++h; // count read 1 if ( V[l]->isRead1() ) rcnt[0]++; // count read 2 if ( V[l]->isRead2() ) rcnt[1]++; // copy alignment pointer if ( V[l]->isRead1() || V[l]->isRead2() ) V[o++] = V[l]; l = h; } V.resize(o); // if we have read1 and read2 if ( V.size() > 1 && rcnt[0] && rcnt[1] ) { // iterate over read 1 for ( uint64_t r1 = 0; r1 < rcnt[0]; ++r1 ) // iterate over read 2 for ( uint64_t r2 = rcnt[0]; r2 < o; ++r2 ) { // get alignment for read 1 libmaus2::bambam::BamAlignment const * algn1 = V[r1]; // get alignment for read 2 libmaus2::bambam::BamAlignment const * algn2 = V[r2]; // if pair is marked with gene pair we are looking for if ( ( hasGeneComment(algn1,IS.geneA.name) && hasGeneComment(algn2,IS.geneB.name) ) || ( hasGeneComment(algn1,IS.geneB.name) && hasGeneComment(algn2,IS.geneA.name) ) ) { #if 0 std::cerr << "\n --- \n"; std::cerr << algn1->formatAlignment(*uheader) << std::endl; std::cerr << algn2->formatAlignment(*uheader) << std::endl; ++cnt; std::cerr << "subcnt=" << V.size() << std::endl; #endif // increment number of read pairs found cnt += 1; // determine smaller and larger alignment (by position) bool const smal1 = PosComparator::compare(algn1,algn2); libmaus2::bambam::BamAlignment const * algnl = smal1 ? algn1 : algn2; libmaus2::bambam::BamAlignment const * algnr = smal1 ? algn2 : algn1; // "left" interval libmaus2::math::IntegerInterval<int64_t> intl( algnl->getPos(), algnl->getAlignmentEnd() ); // "right" interval libmaus2::math::IntegerInterval<int64_t> intr( algnr->getPos(), algnr->getAlignmentEnd() ); // construct mapped pair of aligned intervals MappedPair MP(intl,intr); // see if this interval (modulo insert size) already exists bool existing = false; for ( uint64_t i = 0; (!existing) && i < pairs.size(); ++i ) // already seen? if ( MappedPair::isInsertSizeOverlap(pairs[i],MP,insertsize) ) { // update from for left pairs[i].first.from = std::min( MP.first.from, pairs[i].first.from ); // update to for left pairs[i].first.to = std::max( MP.first.to, pairs[i].first.to ); // update from for right pairs[i].second.from = std::min( MP.second.from, pairs[i].second.from ); // update to for right pairs[i].second.to = std::max( MP.second.to, pairs[i].second.to ); // update number of supporting pair for this "break point" pairs[i].cnt += 1; // note that this break point already existed existing = true; } #if 0 else { std::cerr << "no overlap" << std::endl; std::cerr << MP << std::endl; std::cerr << pairs[i] << std::endl; } #endif // push new pair if break point did not exist yet if ( ! existing ) pairs.push_back(MP); } } } } // std::cerr << IS.instances[i] << " gcnt=" << cnt << ((IS.instances[i].num != cnt) ? "___" : "") << std::endl; std::ostringstream ostr; ostr << "\t" << IS.instances[i]; // sort by number of supporting read pairs std::sort(pairs.begin(),pairs.end(),MappedPairCountComparator()); // maximum count uint64_t const maxcnt = pairs.size() ? pairs.front().cnt : 0; ostr << "\t" << maxcnt; // output break points for ( uint64_t j = 0; j < pairs.size();++j ) ostr << "\t" << pairs[j]; // sub instances map ordered by number of read pairs supporting break point subinst[SubInstKey(maxcnt,IS.instances[i].num)].push_back(ostr.str()); // return alignment to free list for ( uint64_t i = 0; i < retlist.size(); ++i ) BAFL.put(retlist[i]); } // output instance lines for ( std::map<SubInstKey, std::vector<std::string>, std::greater<SubInstKey> >::const_iterator ita = subinst.begin(); ita != subinst.end(); ++ita ) { std::vector<std::string> const & V = ita->second; for ( uint64_t i = 0; i < V.size(); ++i ) std::cout << V[i] << "\n"; } } ilow = ihigh; } } } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } }
//Programa Principal int main(void) { char jogador[20], palavra[20], dica[20], corpo[20], achou[20], arquivo[20], aux_letra[20], letra; int creditos, pontos, flag, tam_palavra, tam_letra, i_arquivo, i; system("title Jogo Da Forca"); //Título na Janela intr(); textcolor(red); printf("\n\t\tDigite seu nome: "); textcolor(blue); gets(jogador); textcolor(lightgreen); printf("\n\t\tPE%cA PARA OUTRA PESSOA DIGITAR...", 128); getchar(); clrscr(); textcolor(yellow); printf("\n\t\tPALAVRA CHAVE: "); textcolor(cyan); gets(palavra); textcolor(lightgreen); printf("\n\t\tDICA: "); textcolor(red); gets(dica); clrscr(); //Reset variáveis i_arquivo=0; creditos=6; pontos=0; tam_palavra=strlen(palavra); for (i=0; i<tam_palavra; i++) { if (palavra[i]==' ') { achou[i]=' '; pontos++; } else { palavra[i]=toupper(palavra[i]); achou[i]='_'; } } for (i=0; i<20; i++) { arquivo[i]=' '; } for (i=0; i<6; i++) { corpo[i]=' '; } for (i=0; jogador[i]!='\0'; i++) { jogador[i]=toupper(jogador[i]); } for (i=0; dica[i]!='\0'; i++) { dica[i]=toupper(dica[i]); } clrscr(); textcolor(yellow); printf ("JOGO DA FORCA 1.0\n\n"); mostra_forca(corpo, creditos); printf ("\n\n"); mostra_achou(achou, tam_palavra); printf ("\n\n"); puts (dica); printf ("\n"); while ((creditos>0)&&(pontos<tam_palavra)) { flag=0; textcolor(cyan); printf ("LETRA: "); gets (aux_letra); tam_letra=strlen(aux_letra); if (tam_letra!=1) { printf ("DIGITE \"UMA\" LETRA!\n"); getch (); flag=1; } else { letra=toupper(aux_letra[0]); arquivo[i_arquivo]=letra; if (letras_usadas (arquivo, i_arquivo)) { printf ("ESTA LETRA JA FOI!"); getch (); arquivo[i_arquivo]=' '; flag=1; } else { arquivo[i_arquivo]=letra; i_arquivo++; for (i=0; i<tam_palavra; i++) { if (letra==palavra[i]) { achou[i]=letra; flag=1; pontos++; } } } } if (flag==0) { printf ("ESTA LETRA NAO TEM!", jogador); getch (); creditos--; switch (creditos) { case 0: corpo[0]='\\'; break; case 1: corpo[1]='/'; break; case 2: corpo[2]='-'; break; case 3: corpo[3]='-'; break; case 4: corpo[4]='|'; break; case 5: corpo[5]='O'; break; } } //Status do jogo system ("cls"); printf ("JOGO DA FORCA 1.0\n\n"); mostra_forca(corpo, creditos); printf ("\n\n"); mostra_achou(achou, tam_palavra); printf ("\n\n"); puts (dica); printf ("\n"); printf ("LETRAS JA USADAS: "); for (i=0; i<=i_arquivo; i++) { printf ("%c ", toupper(arquivo[i])); } printf ("\n\n"); //Resultado Final if (pontos==tam_palavra) { printf ("%s, VOCE GANHOU!\n", jogador); } if (creditos==0) { textcolor(red); printf ("%s, VOCE PERDEU!\n", jogador); textcolor(cyan); printf ("A PALAVRA ERA "); textcolor(yellow); puts (palavra); printf ("\n"); } } getch (); }
enum loop_return loop(int toplevel, int justonce) { Eprog prog; int err, non_empty = 0; queue_signals(); pushheap(); if (!toplevel) zcontext_save(); for (;;) { freeheap(); if (stophist == 3) /* re-entry via preprompt() */ hend(NULL); hbegin(1); /* init history mech */ if (isset(SHINSTDIN)) { setblock_stdin(); if (interact && toplevel) { int hstop = stophist; stophist = 3; /* * Reset all errors including the interrupt error status * immediately, so preprompt runs regardless of what * just happened. We'll reset again below as a * precaution to ensure we get back to the command line * no matter what. */ errflag = 0; preprompt(); if (stophist != 3) hbegin(1); else stophist = hstop; /* * Reset all errors, including user interupts. * This is what allows ^C in an interactive shell * to return us to the command line. */ errflag = 0; } } use_exit_printed = 0; intr(); /* interrupts on */ lexinit(); /* initialize lexical state */ if (!(prog = parse_event(ENDINPUT))) { /* if we couldn't parse a list */ hend(NULL); if ((tok == ENDINPUT && !errflag) || (tok == LEXERR && (!isset(SHINSTDIN) || !toplevel)) || justonce) break; if (exit_pending) { /* * Something down there (a ZLE function?) decided * to exit when there was stuff to clear up. * Handle that now. */ stopmsg = 1; zexit(exit_pending >> 1, 0); } if (tok == LEXERR && !lastval) lastval = 1; continue; } if (hend(prog)) { enum lextok toksav = tok; non_empty = 1; if (toplevel && (getshfunc("preexec") || paramtab->getnode(paramtab, "preexec" HOOK_SUFFIX))) { LinkList args; char *cmdstr; /* * As we're about to freeheap() or popheap() * anyway, there's no gain in using permanent * storage here. */ args = newlinklist(); addlinknode(args, "preexec"); /* If curline got dumped from the history, we don't know * what the user typed. */ if (hist_ring && curline.histnum == curhist) addlinknode(args, hist_ring->node.nam); else addlinknode(args, ""); addlinknode(args, dupstring(getjobtext(prog, NULL))); addlinknode(args, cmdstr = getpermtext(prog, NULL, 0)); callhookfunc("preexec", args, 1, NULL); /* The only permanent storage is from getpermtext() */ zsfree(cmdstr); /* * Note this does *not* remove a user interrupt error * condition, even though we're at the top level loop: * that would be inconsistent with the case where * we didn't execute a preexec function. This is * an implementation detail that an interrupting user * does't care about. */ errflag &= ~ERRFLAG_ERROR; } if (stopmsg) /* unset 'you have stopped jobs' flag */ stopmsg--; execode(prog, 0, 0, toplevel ? "toplevel" : "file"); tok = toksav; if (toplevel) noexitct = 0; } if (ferror(stderr)) { zerr("write error"); clearerr(stderr); } if (subsh) /* how'd we get this far in a subshell? */ exit(lastval); if (((!interact || sourcelevel) && errflag) || retflag) break; if (isset(SINGLECOMMAND) && toplevel) { dont_queue_signals(); if (sigtrapped[SIGEXIT]) dotrap(SIGEXIT); exit(lastval); } if (justonce) break; }
/* Also: The contents of both buffers is monitored in order to check if they got overflowed during the MUX call. If so, the executation is aborted. */ int runExtension(char * const command, char * const line) { int clen, llen; union REGPACK r; char *p; int rc = 0; /* Default: is no extension */ assert(command); assert(line); assert(strlen(command) < BUFFER_SIZE_MUX_AE); assert(strlen(line) <= BUFFER_SIZE_MUX_AE); assert(FP_SEG(command) == FP_SEG(line)); /* Fill the length bytes */ command[-1] = (char)(clen = strlen(command)); line[-1] = (char)(llen = strlen(line)); command[-2] = line[-2] = (char)BUFFER_SIZE_MUX_AE; /* 4dos v4 compatible space padding */ memset(command + clen, ' ', BUFFER_SIZE_MUX_AE - clen); /* The command line is \xd terminated, for savety reasons an \0 is added too */ strcat(line + llen, "\xd"); line[BUFFER_SIZE_MUX_AE] = '\0'; /* Both strings have been prepared now; the MUX call is going to happen */ r.r_ax = 0xae00; /* Installable Commands check for extension */ r.r_dx = 0xffff; /* Magic value */ r.r_cx = -llen; /* length of command line tail (4dos v4) */ r.r_ds = r.r_es = FP_SEG(command); r.r_bx = FP_OFF(line) - 2; r.r_si = FP_OFF(command) - 1; r.r_di = 0; /* Magic value 4dos v4 */ intr(0x2F, &r); switch(r.r_ax & 0xFF) { case 0x00: /* No appropriate extension found */ break; default: /* Invalid response */ dprintf( ("[Invalid response from Installable Commands handler: 0x%02x]\n", r.r_ax & 0xFF) ); break; case 0xFF: /* Is an extension -> execute the Installable Command */ r.r_ax = 0xae01; intr(0x2F, &r); invalidateNLSbuf(); if(command[-1] == 0) /* The command had been processed */ rc = 1; /* Stop interpreting the command */ else rc = 2; /* buffers rewritten */ break; } /* Cleanup: Adjust buffers and check for overflow */ if((unsigned char)line[-2] != BUFFER_SIZE_MUX_AE #if BUFFER_SIZE_MUX_AE < 255 || (unsigned char)line[-1] > BUFFER_SIZE_MUX_AE #endif || line[BUFFER_SIZE_MUX_AE]) { /* Yiek! That looks very much like an overflow!! */ dprintf( ("[Memory corrupted during Installable Commands handler]\n") ); longjmp(jmp_beginning, E_CorruptMemory); } /* Check command and transform it back into C-style string */ p = command + command[-1]; while(--p >= command && isspace(*p)); p[1] = 0; /* Check the command line and transform it into a C-style string */ /* Must terminate as line[BUFFER_SIZE] == 0 */ line[(unsigned char)line[-1]] = line[(unsigned char)line[-2]] = '\0'; if(0 != (p = strchr(line, '\xd'))) *p = 0; return rc; }
const Distribution1D *SpatialLightDistribution::Lookup(const Point3f &p) const { ProfilePhase _(Prof::LightDistribLookup); ++nLookups; // Compute integer voxel coordinates for the given point |p| with // respect to the overall voxel grid. Vector3f offset = scene.WorldBound().Offset(p); // offset in [0,1]. Point3i pi; for (int i = 0; i < 3; ++i) pi[i] = int(offset[i] * nVoxels[i]); // Create the per-thread cache of sampling distributions if needed. LocalBucketHash *localVoxelDistribution = localVoxelDistributions[ThreadIndex].get(); if (!localVoxelDistribution) { LOG(INFO) << "Created per-thread SpatialLightDistribution for thread" << ThreadIndex; localVoxelDistribution = new LocalBucketHash; localVoxelDistributions[ThreadIndex].reset(localVoxelDistribution); } else { // Otherwise see if we have a sampling distribution for the voxel // that |p| is in already available in the local cache. auto iter = localVoxelDistribution->find(pi); if (iter != localVoxelDistribution->end()) return iter->second; } // Now we need to either get the distribution from the shared hash // table (if another thread has already created it), or create it // ourselves and add it to the shared table. ProfilePhase __(Prof::LightDistribLookupL2); // First, compute a hash into the first-level hash table. size_t hash = std::hash<int>{}(pi[0] + nVoxels[0] * pi[1] + nVoxels[0] * nVoxels[1] * pi[2]); hash &= (nBuckets - 1); // Acquire the lock for the corresponding second-level hash table. std::lock_guard<std::mutex> lock(mutexes[hash]); // See if we can find it. auto iter = voxelDistribution[hash].find(pi); if (iter != voxelDistribution[hash].end()) { // Success. Add the pointer to the thread-specific hash table so // that we can look up this distribution more efficiently in the // future. (*localVoxelDistribution)[pi] = iter->second.get(); return iter->second.get(); } // We need to compute a new sampling distriibution for this voxel. Note // that we're holding the lock for the first-level hash table bucket // throughout the following; in general, we'd like to do the following // quickly so that other threads don't get held up waiting for that // lock (for this or other voxels that share it). ProfilePhase ___(Prof::LightDistribCreation); ++nCreated; ++nDistributions; // Compute the world-space bounding box of the voxel. Point3f p0(Float(pi[0]) / Float(nVoxels[0]), Float(pi[1]) / Float(nVoxels[1]), Float(pi[2]) / Float(nVoxels[2])); Point3f p1(Float(pi[0] + 1) / Float(nVoxels[0]), Float(pi[1] + 1) / Float(nVoxels[1]), Float(pi[2] + 1) / Float(nVoxels[2])); Bounds3f voxelBounds(scene.WorldBound().Lerp(p0), scene.WorldBound().Lerp(p1)); // Compute the sampling distribution. Sample a number of points inside // voxelBounds using a 3D Halton sequence; at each one, sample each // light source and compute a weight based on Li/pdf for the light's // sample (ignoring visibility between the point in the voxel and the // point on the light source) as an approximation to how much the light // is likely to contribute to illumination in the voxel. int nSamples = 128; std::vector<Float> lightContrib(scene.lights.size(), Float(0)); for (int i = 0; i < nSamples; ++i) { Point3f po = voxelBounds.Lerp(Point3f( RadicalInverse(0, i), RadicalInverse(1, i), RadicalInverse(2, i))); Interaction intr(po, Normal3f(), Vector3f(), Vector3f(1, 0, 0), 0 /* time */, MediumInterface()); // Use the next two Halton dimensions to sample a point on the // light source. Point2f u(RadicalInverse(3, i), RadicalInverse(4, i)); for (size_t j = 0; j < scene.lights.size(); ++j) { Float pdf; Vector3f wi; VisibilityTester vis; Spectrum Li = scene.lights[j]->Sample_Li(intr, u, &wi, &pdf, &vis); if (pdf > 0) { // TODO: look at tracing shadow rays / computing beam // transmittance. Probably shouldn't give those full weight // but instead e.g. have an occluded shadow ray scale down // the contribution by 10 or something. lightContrib[j] += Li.y() / pdf; } } } // We don't want to leave any lights with a zero probability; it's // possible that a light contributes to points in the voxel even though // we didn't find such a point when sampling above. Therefore, compute // a minimum (small) weight and ensure that all lights are given at // least the corresponding probability. Float sumContrib = std::accumulate(lightContrib.begin(), lightContrib.end(), Float(0)); Float avgContrib = sumContrib / (nSamples * lightContrib.size()); Float minContrib = (avgContrib > 0) ? .001 * avgContrib : 1; for (size_t i = 0; i < lightContrib.size(); ++i) { VLOG(2) << "Voxel pi = " << pi << ", light " << i << " contrib = " << lightContrib[i]; lightContrib[i] = std::max(lightContrib[i], minContrib); } LOG(INFO) << "Initialized light distribution in voxel pi= " << pi << ", avgContrib = " << avgContrib; // Compute a sampling distribution from the accumulated // contributions. std::unique_ptr<Distribution1D> distrib( new Distribution1D(&lightContrib[0], lightContrib.size())); // Store a pointer to it in the per-thread cache for the future. (*localVoxelDistribution)[pi] = distrib.get(); // Store the canonical unique_ptr for it in the global hash table so // other threads can use it. voxelDistribution[hash][pi] = std::move(distrib); return (*localVoxelDistribution)[pi]; }
char * zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) { char *s, **bracket; int old_errno = errno; int tmout = getiparam("TMOUT"); #if defined(HAVE_POLL) || defined(HAVE_SELECT) /* may not be set, but that's OK since getiparam() returns 0 == off */ baud = getiparam("BAUD"); costmult = (baud) ? 3840000L / baud : 0; #endif /* ZLE doesn't currently work recursively. This is needed in case a * * select loop is used in a function called from ZLE. vared handles * * this differently itself. */ if(zleactive) { char *pptbuf; int pptlen; pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL, &pmpt_attr), &pptlen); write_loop(2, pptbuf, pptlen); free(pptbuf); return shingetline(); } /* * The current status is what we need if we are going * to display a prompt. We'll remember it here for * use further in. */ pre_zle_status = lastval; keytimeout = (time_t)getiparam("KEYTIMEOUT"); if (!shout) { if (SHTTY != -1) init_shout(); if (!shout) return NULL; /* We could be smarter and default to a system read. */ /* If we just got a new shout, make sure the terminal is set up. */ if (termflags & TERM_UNKNOWN) init_term(); } fflush(shout); fflush(stderr); intr(); insmode = unset(OVERSTRIKE); eofsent = 0; resetneeded = 0; fetchttyinfo = 0; trashedzle = 0; raw_lp = lp; lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL, &pmpt_attr); raw_rp = rp; rpmpt_attr = pmpt_attr; rpromptbuf = promptexpand(rp ? *rp : NULL, 1, NULL, NULL, &rpmpt_attr); free_prepostdisplay(); zlereadflags = flags; zlecontext = context; histline = curhist; vistartchange = -1; zleline = (ZLE_STRING_T)zalloc(((linesz = 256) + 2) * ZLE_CHAR_SIZE); *zleline = ZWC('\0'); virangeflag = lastcmd = done = zlecs = zlell = mark = 0; vichgflag = 0; viinsbegin = 0; statusline = NULL; selectkeymap("main", 1); initundo(); fixsuffix(); if ((s = getlinknode(bufstack))) { setline(s, ZSL_TOEND); zsfree(s); if (stackcs != -1) { zlecs = stackcs; stackcs = -1; if (zlecs > zlell) zlecs = zlell; CCLEFT(); } if (stackhist != -1) { histline = stackhist; stackhist = -1; } handleundo(); } /* * If main is linked to the viins keymap, we need to register * explicitly that we're now in vi insert mode as there's * no user operation to indicate this. */ if (openkeymap("main") == openkeymap("viins")) viinsert_init(); selectlocalmap(NULL); if (isset(PROMPTCR)) putc('\r', shout); if (tmout) alarm(tmout); /* * On some windowing systems we may enter this function before the * terminal is fully opened and sized, resulting in an infinite * series of SIGWINCH when the handler prints the prompt before we * have done so here. Therefore, hold any such signal until the * first full refresh has completed. The important bit is that the * handler must not see zleactive = 1 until ZLE really is active. * See the end of adjustwinsize() in Src/utils.c */ queue_signals(); zleactive = 1; resetneeded = 1; /* * Start of the main zle read. * Fully reset error conditions, including user interrupt. */ errflag = retflag = 0; lastcol = -1; initmodifier(&zmod); prefixflag = 0; zrefresh(); unqueue_signals(); /* Should now be safe to acknowledge SIGWINCH */ zlecallhook(init, NULL); if ((bracket = getaparam("zle_bracketed_paste")) && arrlen(bracket) == 2) fputs(*bracket, shout); zrefresh(); zlecore(); if (errflag) setsparam((zlecontext == ZLCON_VARED) ? "ZLE_VARED_ABORTED" : "ZLE_LINE_ABORTED", zlegetline(NULL, NULL)); if ((bracket = getaparam("zle_bracketed_paste")) && arrlen(bracket) == 2) fputs(bracket[1], shout); if (done && !exit_pending && !errflag) zlecallhook(finish, NULL); statusline = NULL; invalidatelist(); trashzle(); free(lpromptbuf); free(rpromptbuf); zleactive = zlereadflags = lastlistlen = zlecontext = 0; alarm(0); freeundo(); if (eofsent || errflag || exit_pending) { s = NULL; } else { zleline[zlell++] = ZWC('\n'); s = zlegetline(NULL, NULL); } free(zleline); zleline = NULL; forget_edits(); errno = old_errno; /* highlight no longer valid */ set_region_highlight(NULL, NULL); return s; }
void loop(int toplevel, int justonce) { List list; #ifdef DEBUG int oasp = toplevel ? 0 : alloc_stackp; #endif pushheap(); for (;;) { freeheap(); errflag = 0; if (isset(SHINSTDIN)) { setblock_stdin(); if (interact) preprompt(); } hbegin(); /* init history mech */ intr(); /* interrupts on */ lexinit(); /* initialize lexical state */ if (!(list = parse_event())) { /* if we couldn't parse a list */ hend(); if ((tok == ENDINPUT && !errflag) || justonce) break; continue; } if (hend()) { int toksav = tok; List prelist; if (toplevel && (prelist = getshfunc("preexec")) != &dummy_list) { Histent he = gethistent(curhist); LinkList args; PERMALLOC { args = newlinklist(); addlinknode(args, "preexec"); if (he && he->text) addlinknode(args, he->text); } LASTALLOC; doshfunc(prelist, args, 0, 1); freelinklist(args, (FreeFunc) NULL); errflag = 0; } if (stopmsg) /* unset 'you have stopped jobs' flag */ stopmsg--; execlist(list, 0, 0); tok = toksav; if (toplevel) noexitct = 0; } DPUTS(alloc_stackp != oasp, "BUG: alloc_stackp changed in loop()"); if (ferror(stderr)) { zerr("write error", NULL, 0); clearerr(stderr); } if (subsh) /* how'd we get this far in a subshell? */ exit(lastval); if (((!interact || sourcelevel) && errflag) || retflag) break; if (trapreturn) { lastval = trapreturn; trapreturn = 0; } if (isset(SINGLECOMMAND) && toplevel) { if (sigtrapped[SIGEXIT]) dotrap(SIGEXIT); exit(lastval); } if (justonce) break; }
void int10ax0003(struct REGPACK *regs) { regs->r_ax=0x0003; intr(0x10,regs); }
bool IntrSegment3Sphere3<Real>::Find (Real tmax, const Vector3<Real>& velocity0, const Vector3<Real>& velocity1) { // Check if initially intersecting. if (Find()) { mContactTime = (Real)0; mIntersectionType = IT_OTHER; return true; } // Substract the segment velocity from the sphere velocity so that // the calculations are based in the coordinate system of the segment. // In this system, the line is of course stationary. The sphere spans // a capsule, but instead we will "grow" the segment by the sphere radius // and shrink the sphere to its center. The problem is now to detect // the first time the moving center intersects the capsule formed by // the line segment and sphere radius. Capsule3<Real> capsule; capsule.Segment = *mSegment; capsule.Radius = mSphere->Radius; Vector3<Real> relVelocity = velocity1 - velocity0; Real relSpeed = relVelocity.Normalize(); Segment3<Real> path; path.Extent = ((Real)0.5)*tmax*relSpeed; path.Direction = relVelocity; // unit-length vector path.Center = mSphere->Center + path.Extent*path.Direction; IntrSegment3Capsule3<Real> intr(path, capsule); if (!intr.Find()) { mIntersectionType = IT_EMPTY; return false; } // We now know the sphere will intersect the segment. This can happen // either at a segment end point or at a segment interior point. We // need to determine which. mContactTime = (intr.GetParameter(0) + path.Extent)/relSpeed; mQuantity = 1; mIntersectionType = IT_POINT; Vector3<Real> MCenter = mSphere->Center + mContactTime*velocity1; Vector3<Real> MOrigin = mSegment->Center + mContactTime*velocity0; Real origin = mSegment->Direction.Dot(MOrigin); Real negEnd = origin - mSegment->Extent; Real posEnd = origin + mSegment->Extent; Real center = mSegment->Direction.Dot(MCenter); if (center < negEnd) { // Intersection at segment end point P-e*D. mPoint[0] = MOrigin - mSegment->Extent*mSegment->Direction; } else if (center > posEnd) { // Intersection at segment end point P+e*D. mPoint[0] = MOrigin + mSegment->Extent*mSegment->Direction; } else { // Intersection with interior point on edge. Use the projection // along direction axis to find which point that is. mPoint[0] = MOrigin + (center - origin)*mSegment->Direction; } return true; }
/* load 'r' from value 'sv' */ void load(int r, SValue *sv) { int v, ft, fc, fr, sign; uint32_t op; SValue v1; fr = sv->r; ft = sv->type.t; fc = sv->c.ul; if(fc>=0) sign=0; else { sign=1; fc=-fc; } v = fr & VT_VALMASK; if (fr & VT_LVAL) { uint32_t base = 0xB; // fp if(v == VT_LLOCAL) { v1.type.t = VT_PTR; v1.r = VT_LOCAL | VT_LVAL; v1.c.ul = sv->c.ul; load(base=14 /* lr */, &v1); fc=sign=0; v=VT_LOCAL; } else if(v == VT_CONST) { v1.type.t = VT_PTR; v1.r = fr&~VT_LVAL; v1.c.ul = sv->c.ul; v1.sym=sv->sym; load(base=14, &v1); fc=sign=0; v=VT_LOCAL; } else if(v < VT_CONST) { base=intr(v); fc=sign=0; v=VT_LOCAL; } if(v == VT_LOCAL) { if(is_float(ft)) { calcaddr(&base,&fc,&sign,1020,2); #ifdef TCC_ARM_VFP op=0xED100A00; /* flds */ if(!sign) op|=0x800000; if ((ft & VT_BTYPE) != VT_FLOAT) op|=0x100; /* flds -> fldd */ o(op|(vfpr(r)<<12)|(fc>>2)|(base<<16)); #else op=0xED100100; if(!sign) op|=0x800000; #if LDOUBLE_SIZE == 8 if ((ft & VT_BTYPE) != VT_FLOAT) op|=0x8000; #else if ((ft & VT_BTYPE) == VT_DOUBLE) op|=0x8000; else if ((ft & VT_BTYPE) == VT_LDOUBLE) op|=0x400000; #endif o(op|(fpr(r)<<12)|(fc>>2)|(base<<16)); #endif } else if((ft & (VT_BTYPE|VT_UNSIGNED)) == VT_BYTE || (ft & VT_BTYPE) == VT_SHORT) { calcaddr(&base,&fc,&sign,255,0); op=0xE1500090; if ((ft & VT_BTYPE) == VT_SHORT) op|=0x20; if ((ft & VT_UNSIGNED) == 0) op|=0x40; if(!sign) op|=0x800000; o(op|(intr(r)<<12)|(base<<16)|((fc&0xf0)<<4)|(fc&0xf)); } else { calcaddr(&base,&fc,&sign,4095,0); op=0xE5100000; if(!sign) op|=0x800000; if ((ft & VT_BTYPE) == VT_BYTE) op|=0x400000; o(op|(intr(r)<<12)|fc|(base<<16)); } return; }
void int10ax08(struct REGPACK *regs) { regs->r_ax=0x0800; regs->r_bx=0x0000; intr(0x10,regs); }
Distribution1D * SpatialLightDistribution::ComputeDistribution(Point3i pi) const { ProfilePhase _(Prof::LightDistribCreation); ++nCreated; ++nDistributions; // Compute the world-space bounding box of the voxel corresponding to // |pi|. Point3f p0(Float(pi[0]) / Float(nVoxels[0]), Float(pi[1]) / Float(nVoxels[1]), Float(pi[2]) / Float(nVoxels[2])); Point3f p1(Float(pi[0] + 1) / Float(nVoxels[0]), Float(pi[1] + 1) / Float(nVoxels[1]), Float(pi[2] + 1) / Float(nVoxels[2])); Bounds3f voxelBounds(scene.WorldBound().Lerp(p0), scene.WorldBound().Lerp(p1)); // Compute the sampling distribution. Sample a number of points inside // voxelBounds using a 3D Halton sequence; at each one, sample each // light source and compute a weight based on Li/pdf for the light's // sample (ignoring visibility between the point in the voxel and the // point on the light source) as an approximation to how much the light // is likely to contribute to illumination in the voxel. int nSamples = 128; std::vector<Float> lightContrib(scene.lights.size(), Float(0)); for (int i = 0; i < nSamples; ++i) { Point3f po = voxelBounds.Lerp(Point3f( RadicalInverse(0, i), RadicalInverse(1, i), RadicalInverse(2, i))); Interaction intr(po, Normal3f(), Vector3f(), Vector3f(1, 0, 0), 0 /* time */, MediumInterface()); // Use the next two Halton dimensions to sample a point on the // light source. Point2f u(RadicalInverse(3, i), RadicalInverse(4, i)); for (size_t j = 0; j < scene.lights.size(); ++j) { Float pdf; Vector3f wi; VisibilityTester vis; Spectrum Li = scene.lights[j]->Sample_Li(intr, u, &wi, &pdf, &vis); if (pdf > 0) { // TODO: look at tracing shadow rays / computing beam // transmittance. Probably shouldn't give those full weight // but instead e.g. have an occluded shadow ray scale down // the contribution by 10 or something. lightContrib[j] += Li.y() / pdf; } } } // We don't want to leave any lights with a zero probability; it's // possible that a light contributes to points in the voxel even though // we didn't find such a point when sampling above. Therefore, compute // a minimum (small) weight and ensure that all lights are given at // least the corresponding probability. Float sumContrib = std::accumulate(lightContrib.begin(), lightContrib.end(), Float(0)); Float avgContrib = sumContrib / (nSamples * lightContrib.size()); Float minContrib = (avgContrib > 0) ? .001 * avgContrib : 1; for (size_t i = 0; i < lightContrib.size(); ++i) { VLOG(2) << "Voxel pi = " << pi << ", light " << i << " contrib = " << lightContrib[i]; lightContrib[i] = std::max(lightContrib[i], minContrib); } LOG(INFO) << "Initialized light distribution in voxel pi= " << pi << ", avgContrib = " << avgContrib; // Compute a sampling distribution from the accumulated contributions. return new Distribution1D(&lightContrib[0], lightContrib.size()); }