std::map<u32,DisassemblyEntry*>::iterator findDisassemblyEntry(std::map<u32,DisassemblyEntry*>& entries, u32 address, bool exact) { if (exact) return entries.find(address); if (entries.size() == 0) return entries.end(); // find first elem that's >= address auto it = entries.lower_bound(address); if (it != entries.end()) { // it may be an exact match if (isInInterval(it->second->getLineAddress(0),it->second->getTotalSize(),address)) return it; // otherwise it may point to the next if (it != entries.begin()) { it--; if (isInInterval(it->second->getLineAddress(0),it->second->getTotalSize(),address)) return it; } } // check last entry manually auto rit = entries.rbegin(); if (isInInterval(rit->second->getLineAddress(0),rit->second->getTotalSize(),address)) { return (++rit).base(); } // no match otherwise return entries.end(); }
VariablesGrid VariablesGrid::getTimeSubGrid( double startTime, double endTime ) const { uint startIdx = getCeilIndex( startTime ); uint endIdx = getFloorIndex( endTime ); VariablesGrid newVariablesGrid; if ( ( isInInterval( startTime ) == BT_FALSE ) || ( isInInterval( endTime ) == BT_FALSE ) ) return newVariablesGrid; if ( ( startIdx >= getNumPoints( ) ) || ( endIdx >= getNumPoints( ) ) ) return newVariablesGrid; // if ( startIdx > endIdx ) // return newVariablesGrid; // add all matrices in interval (constant interpolation) if ( ( hasTime( startTime ) == BT_FALSE ) && ( startIdx > 0 ) ) newVariablesGrid.addMatrix( *(values[ startIdx-1 ]),startTime ); for( uint i=startIdx; i<=endIdx; ++i ) newVariablesGrid.addMatrix( *(values[i]),getTime( i ) ); if ( hasTime( endTime ) == BT_FALSE ) newVariablesGrid.addMatrix( *(values[ endIdx ]),endTime ); return newVariablesGrid; }
static bool checkStart(u32 start, u32 size) { bool invalidSize = false; bool invalidAddress = false; if (isInInterval(PSP_GetScratchpadMemoryBase(),PSP_GetScratchpadMemoryEnd(),start)) { invalidSize = !isInInterval(PSP_GetScratchpadMemoryBase(),PSP_GetScratchpadMemoryEnd(),start+size-1); } else if (isInInterval(PSP_GetVidMemBase(),PSP_GetVidMemEnd(),start)) { invalidSize = !isInInterval(PSP_GetVidMemBase(),PSP_GetVidMemEnd(),start+size-1); } else if (isInInterval(PSP_GetKernelMemoryBase(),PSP_GetUserMemoryEnd(),start)) { invalidSize = !isInInterval(PSP_GetKernelMemoryBase(),PSP_GetUserMemoryEnd(),start+size-1); } else { invalidAddress = true; } if (invalidAddress) { printf("Invalid address 0x%08X.\n",start); return false; } else if (invalidSize) { printf("Invalid end address 0x%08X.\n",start+size); return false; } return true; }
void _ISRFAST _INT2Interrupt(void) #endif { //LED1 = ~LED1; if (SA02_VIBRA_INTPIN_IF) { uint8_t rtc_min; uint16_t rtc_sec; // get current time from RTC mRtccClearRtcPtr(); rtc_sec = BCDToDecimal(RTCVALL); rtc_min = BCDToDecimal(RTCVALH); rtc_sec += rtc_min*SEC_IN_MIN; //printf("int_cnt: %lu time: %d start_time: %d\n", int_cnt, rtc_sec, sec_start); if (isInInterval(sec_start, rtc_sec)) { // we have enough interrupts in given shaking interval if (int_cnt++ >= INTERRUPTS_FOR_ONE_SHAKE) { accel_int = TRUE; int_cnt = 0; //printf("=== Vibra interrupt ===\n"); } delay_ms(25); } else { sec_start = rtc_sec; // save new starting time int_cnt = 0; } SA02_VIBRA_INTPIN_IF = 0; } // RTC interrupt if ((PIR3bits.RTCCIF) && (PIE3bits.RTCCIE)) { PIR3bits.RTCCIF = 0; PIE3bits.RTCCIE = 0; RtccWrOn(); mRtccOff(); mRtccWrOff(); //printf("RTC INT\n"); } if (HW_isIRQ0Active()) { HW_irq0occurred(); HW_clearIRQ0(); } if (HW_isIRQ1Active()) { HW_irq1occurred(); HW_clearIRQ1(); } //LED1 = ~LED1; }
/// /// Finds the raw interval boundaries corresponding to the provided p-value /// The raw intervals are just connected sections where all bins of the p-value /// histogram _pvalues lie above the given threshold. /// /// \param pvalue - pvalue of the intervals to find /// \param clis - saves intervals into this vector of confidence intervals, usually _clintervals1sigma or _clintervals2sigma /// void CLIntervalMaker::findRawIntervals(float pvalue, vector<CLInterval> &clis) { bool intervalIsOpened = false; int intervalBinLo = 1; int intervalBinHi = _pvalues.GetNbinsX(); // check if we start with an opened interval if ( isInInterval(1, pvalue) ) intervalIsOpened = true; // loop over the pvalue histogram and find the intervals for ( int j=1; j<=_pvalues.GetNbinsX(); j++ ){ if ( intervalIsOpened ){ if ( isInInterval(j, pvalue) && j!=_pvalues.GetNbinsX() ) continue; // right border will close! intervalBinHi = j; intervalIsOpened = false; storeRawInterval(intervalBinLo, intervalBinHi, pvalue, clis); } else{ if ( !isInInterval(j, pvalue) ) continue; intervalBinLo = j; intervalIsOpened = true; } } }
void CtrlDisAsmView::drawArguments(HDC hdc, const DisassemblyLineInfo &line, int x, int y, int textColor, const std::set<std::string> ¤tArguments) { if (line.params.empty()) { return; } // Don't highlight the selected lines. if (isInInterval(selectRangeStart, selectRangeEnd - selectRangeStart, line.info.opcodeAddress)) { TextOutA(hdc, x, y, line.params.c_str(), (int)line.params.size()); return; } int highlightedColor = 0xaabb00; if (textColor == 0x0000ff) { highlightedColor = 0xaabb77; } UINT prevAlign = SetTextAlign(hdc, TA_UPDATECP); MoveToEx(hdc, x, y, NULL); size_t p = 0, nextp = line.params.find(','); while (nextp != line.params.npos) { const std::string arg = line.params.substr(p, nextp - p); if (currentArguments.find(arg) != currentArguments.end() && textColor != 0xffffff) { SetTextColor(hdc, highlightedColor); } TextOutA(hdc, 0, 0, arg.c_str(), (int)arg.size()); SetTextColor(hdc,textColor); p = nextp + 1; nextp = line.params.find(',', p); TextOutA(hdc, 0, 0, ",", 1); } if (p < line.params.size()) { const std::string arg = line.params.substr(p); if (currentArguments.find(arg) != currentArguments.end() && textColor != 0xffffff) { SetTextColor(hdc, highlightedColor); } TextOutA(hdc, 0, 0, arg.c_str(), (int)arg.size()); SetTextColor(hdc,textColor); } SetTextAlign(hdc, prevAlign); }
void Game2D::timer(){ if (pause()) return; if (!evec_.size() && state_==1){ //if (level () >=2) state_=2; //else nextLevel (); } if (state_==1){ bool destroy=0; ship_.onFire(); ship_.timer(direction_, width (), height ()); for (int i=0; i<evec_.size(); i++){ int x1=evec_[i].x (); int y1=evec_[i].y (); int x2=evec_[i].x () + evec_[i].width(); int y2=evec_[i].y () + evec_[i].height(); //ship hit in vertical line if (direction_==1 || direction_==3){ if (isInInterval (ship_.y (), y1, y2) || isInInterval (ship_.y () + ship_.height()/2, y1, y2) || isInInterval (ship_.y () + ship_.height(), y1, y2)){ if (ship_.x() > x1) destroy=ship_.hitMinX(x2); //right else{ if (ship_.x() + ship_.width () > x1) destroy=ship_.hitMaxX(x1-ship_.width ()); //left } } } //ship hit in horizontal line if (direction_==0 || direction_==2){ if (isInInterval (ship_.x (), x1, x2) || isInInterval (ship_.x () + ship_.width()/2, x1, x2) || isInInterval (ship_.x () + ship_.width(), x1, x2)){ if (ship_.y() > y1) destroy=ship_.hitMinY(y2); //down else{ if (ship_.y() + ship_.height () > y1) destroy=ship_.hitMaxY(y1-ship_.height ()); //up } } } if (ship_.fire()){ bool damaged=0; QRect rc; ship_.getFireRect (rc, direction()); //in fire axis y if (direction_==1 || direction_==3){ if (isInInterval (rc.y(), y1, y2) || isInInterval (rc.y()+rc.height(), y1, y2)){ //cross fire line & left enemy || //cross fire line & right enemy if ((x1 > rc.x() && x1 < rc.x()+rc.width()) || (x2 < rc.x() && x2 > rc.x()+rc.width())){ damaged=1; } } } if (direction_==0 || direction_==2){ if (isInInterval (rc.x(), x1, x2) || isInInterval (rc.x()+rc.width(), x1, x2)){ //cross fire line & up enemy || //cross fire line & down enemy if ((y1 > rc.y() && y1 < rc.y()+rc.height()) || (y2 < rc.y() && y2 > rc.y()+rc.height())){ damaged=1; } } } if (damaged){ ++score_; evec_[i].addHealth (-(ship_.damage ())); if (evec_[i].health () == 0) evec_.erase (evec_.begin () + i); } } if (destroy){ state_=2; /*ship_.addHealth (-1); switch(direction_){ case 0: direction_=2; break; case 1: direction_=3; break; case 2: direction_=0; break; case 3: direction_=1; break; } if (ship_.health () == 0) state_=2; */ /*QMessageBox box; box.warning(0,"Game over", "Ship destroyed!", 0, 1); box.show(); */ } } incTime (); if (movable()) moveEnemy (); } }
void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) { if (!debugger->isAlive()) return; PAINTSTRUCT ps; HDC actualHdc = BeginPaint(wnd, &ps); HDC hdc = CreateCompatibleDC(actualHdc); HBITMAP hBM = CreateCompatibleBitmap(actualHdc, rect.right-rect.left, rect.bottom-rect.top); SelectObject(hdc, hBM); SetBkMode(hdc, TRANSPARENT); HPEN nullPen=CreatePen(0,0,0xffffff); HBRUSH nullBrush=CreateSolidBrush(0xffffff); HBRUSH currentBrush=CreateSolidBrush(0xFFEfE8); HPEN oldPen=(HPEN)SelectObject(hdc,nullPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOP); HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOPDISABLE); unsigned int address = windowStart; std::map<u32,int> addressPositions; DisassemblyLineInfo line; for (int i = 0; i < visibleRows; i++) { manager.getLine(address,displaySymbols,line); int rowY1 = rowHeight*i; int rowY2 = rowHeight*(i+1); addressPositions[address] = rowY1; // draw background COLORREF backgroundColor = whiteBackground ? 0xFFFFFF : debugger->getColor(address); COLORREF textColor = 0x000000; if (isInInterval(address,line.totalSize,debugger->getPC())) { backgroundColor = scaleColor(backgroundColor,1.05f); } if (address >= selectRangeStart && address < selectRangeEnd && searching == false) { if (hasFocus) { backgroundColor = address == curAddress ? 0xFF8822 : 0xFF9933; textColor = 0xFFFFFF; } else { backgroundColor = 0xC0C0C0; } } HBRUSH backgroundBrush = CreateSolidBrush(backgroundColor); HPEN backgroundPen = CreatePen(0,0,backgroundColor); SelectObject(hdc,backgroundBrush); SelectObject(hdc,backgroundPen); Rectangle(hdc,0,rowY1,rect.right,rowY1+rowHeight); SelectObject(hdc,currentBrush); SelectObject(hdc,nullPen); DeleteObject(backgroundBrush); DeleteObject(backgroundPen); // display address/symbol bool enabled; if (CBreakPoints::IsAddressBreakPoint(address,&enabled)) { if (enabled) textColor = 0x0000FF; int yOffset = max(-1,(rowHeight-14+1)/2); if (!enabled) yOffset++; DrawIconEx(hdc,2,rowY1+1+yOffset,enabled ? breakPoint : breakPointDisable,32,32,0,0,DI_NORMAL); } SetTextColor(hdc,textColor); char addressText[64]; getDisasmAddressText(address,addressText,true,line.type == DISTYPE_OPCODE); TextOutA(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText)); if (isInInterval(address,line.totalSize,debugger->getPC())) { TextOut(hdc,pixelPositions.opcodeStart-8,rowY1,L"■",1); } // display whether the condition of a branch is met if (line.info.isConditional && address == debugger->getPC()) { line.params += line.info.conditionMet ? " ; true" : " ; false"; } if (line.params.size() != 0) TextOutA(hdc,pixelPositions.argumentsStart,rowY1+2,line.params.c_str(),(int)line.params.size()); SelectObject(hdc,boldfont); TextOutA(hdc,pixelPositions.opcodeStart,rowY1+2,line.name.c_str(),(int)line.name.size()); SelectObject(hdc,font); address += line.totalSize; } std::vector<BranchLine> branchLines = manager.getBranchLines(windowStart,address-windowStart); for (size_t i = 0; i < branchLines.size(); i++) { drawBranchLine(hdc,addressPositions,branchLines[i]); } SelectObject(hdc,oldFont); SelectObject(hdc,oldPen); SelectObject(hdc,oldBrush); // copy bitmap to the actual hdc BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); DeleteObject(hBM); DeleteDC(hdc); DeleteObject(nullPen); DeleteObject(nullBrush); DeleteObject(currentBrush); DestroyIcon(breakPoint); DestroyIcon(breakPointDisable); EndPaint(wnd, &ps); }
bool DumpMemoryWindow::fetchDialogData(HWND hwnd) { char str[256],errorMessage[256]; PostfixExpression exp; // parse start address GetWindowTextA(GetDlgItem(hwnd,IDC_DUMP_STARTADDRESS),str,256); if (cpu->initExpression(str,exp) == false || cpu->parseExpression(exp,start) == false) { sprintf(errorMessage,"Invalid address expression \"%s\".",str); MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } // parse size GetWindowTextA(GetDlgItem(hwnd,IDC_DUMP_SIZE),str,256); if (cpu->initExpression(str,exp) == false || cpu->parseExpression(exp,size) == false) { sprintf(errorMessage,"Invalid size expression \"%s\".",str); MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } if (size == 0) { MessageBoxA(hwnd,"Invalid size 0.","Error",MB_OK); return false; } // get filename GetWindowTextA(GetDlgItem(hwnd,IDC_DUMP_FILENAME),fileName,MAX_PATH); if (strlen(fileName) == 0) return false; // now check if data makes sense... bool invalidSize = false; bool invalidAddress = false; if (isInInterval(PSP_GetScratchpadMemoryBase(),PSP_GetScratchpadMemoryEnd(),start)) { invalidSize = !isInInterval(PSP_GetScratchpadMemoryBase(),PSP_GetScratchpadMemoryEnd(),start+size-1); } else if (isInInterval(PSP_GetVidMemBase(),PSP_GetVidMemEnd(),start)) { invalidSize = !isInInterval(PSP_GetVidMemBase(),PSP_GetVidMemEnd(),start+size-1); } else if (isInInterval(PSP_GetKernelMemoryBase(),PSP_GetUserMemoryEnd(),start)) { invalidSize = !isInInterval(PSP_GetKernelMemoryBase(),PSP_GetUserMemoryEnd(),start+size-1); } else { invalidAddress = true; } if (invalidAddress) { sprintf(errorMessage,"Invalid address 0x%08X.",start); MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } else if (invalidSize) { sprintf(errorMessage,"Invalid end address 0x%08X.",start+size); MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } return true; }