eOSState cMenuSearchMain::ProcessKey(eKeys Key) { bool HadSubMenu = HasSubMenu(); eOSState state = cOsdMenu::ProcessKey(Key); if (exitToMainMenu == 1) { exitToMainMenu = 0; return osBack; } if (!HasSubMenu() && HadSubMenu) UpdateCurrent(); if (state == osUnknown) { switch (Key) { case kFastRew: if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu) { /* if (Count()) { CursorUp(); return ShowSummary(); } */ } else return Shift(-EPGSearchConfig.timeShiftValue); case kFastFwd: if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu) { /* if (Count()) { CursorDown(); return ShowSummary(); } */ } else return Shift(EPGSearchConfig.timeShiftValue); case kRecord: case kRed: if(HasSubMenu()) { UpdateCurrent(); state = Record(); break; } if (Count()) { if (EPGSearchConfig.redkeymode==toggleKeys) state = Record(); else { cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current()); if (mi) { if (mi->event) { return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"),mi->event)); } } } } break; case k0: if(!HasSubMenu()) { toggleKeys = 1 - toggleKeys; SetHelpKeys(true); } state = osContinue; break; case k1...k9: if (!HasSubMenu()) return Commands(Key); else state = osContinue; break; case kGreen: if (schedules) { if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu) { if (Count()) { // CursorUp(); // return ShowSummary(); } } else if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) { int ChannelNr = cDevice::CurrentChannel(); if (Count()) { cMenuMyScheduleItem* Item = (cMenuMyScheduleItem *)Get(Current()); if (Item && Item->event) { cChannel *channel = Channels.GetByChannelID(Item->event->ChannelID(), true, true); if (channel) ChannelNr = channel->Number(); } } if (cMenuWhatsOnSearch::currentShowMode == showFavorites) { InFavoritesMenu = true; return AddSubMenu(new cMenuFavorites()); } else { InWhatsOnMenu = true; return AddSubMenu(new cMenuWhatsOnSearch(schedules, ChannelNr)); } } else { cChannel *channel = Channels.GetByNumber(currentChannel-1,-1); if (channel) { PrepareSchedule(channel); if (channel->Number() != cDevice::CurrentChannel()) { otherChannel = channel->Number(); } Display(); } SetHelpKeys(true); return osContinue; } } case kYellow: if (schedules) { if (HasSubMenu()) { if (Count()) { // CursorDown(); // return ShowSummary(); } } else if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) { cMenuWhatsOnSearch::currentShowMode = showNext; InWhatsOnMenu = true; return AddSubMenu(new cMenuWhatsOnSearch(schedules, cMenuWhatsOnSearch::CurrentChannel())); } else { cChannel *channel = Channels.GetByNumber(currentChannel+1,1); if (channel) { PrepareSchedule(channel); if (channel->Number() != cDevice::CurrentChannel()) { otherChannel = channel->Number(); } Display(); } SetHelpKeys(true); return osContinue; } } break; case kBlue: if (HasSubMenu()) { UpdateCurrent(); return Switch(); } if (EPGSearchConfig.bluekeymode==toggleKeys) return Switch(); else return ExtendedSearch(); break; case kInfo: case kOk: if (Count()) return ShowSummary(); break; default: break; } } if (!HasSubMenu()) { cChannel *ch = cMenuWhatsOnSearch::ScheduleChannel(); InWhatsOnMenu = false; InFavoritesMenu = false; if (ch) { // when switch from the other menus to the schedule, try to keep the same time if (cMenuWhatsOnSearch::shiftTime) { time_t diff = cMenuWhatsOnSearch::seekTime - time(NULL); shiftTime = (diff + (diff>0?30:-30)) / 60 ; } else shiftTime = 0; PrepareSchedule(ch); if (ch->Number() != cDevice::CurrentChannel()) { otherChannel = ch->Number(); } Display(); } else if ((HadSubMenu || gl_TimerProgged) && Update()) { if (gl_TimerProgged) // when using epgsearch's timer edit menu, update is delayed because of SVDRP { gl_TimerProgged = 0; SetHelpKeys(); } Display(); } if (Key != kNone) SetHelpKeys(); if (gl_InfoConflict) { gl_InfoConflict = 0; if (Interface->Confirm(tr("Timer conflict! Show?"))) return AddSubMenu(new cMenuConflictCheck()); } } return state; }
void FaultGenerator::Generate(sint8 *outmap, sint32 outwidth, sint32 outheight, IC3Rand *randgen, const double *settings, sint32 numSettings) #endif { sint32 faults, f; if(numSettings >= 1) { faults = sint32(settings[0]); } else { faults = 500; } double lenCoeff; if(numSettings >= 2) { lenCoeff = settings[1]; } else { lenCoeff = 1.0; } sint32 length = static_cast<sint32>(std::min(outwidth, outheight) * lenCoeff); #define PI 3.1415926535 #define ANGLERANGE (((PI / 4.0) * 2.0) - (PI / 4.0)) for(f = 0; f < faults; f++) { sint32 sx = randgen->Next(outwidth), sy = randgen->Next(outheight); sint32 x, y; sint32 horiz = randgen->Next(100) < 50; sint32 dir = randgen->Next(100) < 50; if(horiz) { double yslope = (double)(randgen->Next(1800) - 900) / 1000.0; x = sx; for(sint32 w = 0; w < length; w++) { y = sint32(sy + ((double)w * yslope)); while(y >= outheight) y -= outheight; while(y < 0) y += outheight; Shift(outmap, x, y, outwidth, outheight, false, 1, yslope, length / 2, dir ? -1 : 1); Shift(outmap, x, y, outwidth, outheight, false, -1, 0 - yslope, length / 2, dir ? 1 : -1); x++; if(x >= outwidth) x = 0; } } else { double xslope = (double)(randgen->Next(1800) - 900) / 1000.0; y = sy; for(sint32 h = 0; h < length; h++) { x = sint32(sx + ((double)h * xslope)); while(x >= outwidth) x -= outwidth; while(x < 0) x += outwidth; Shift(outmap, x, y, outwidth, outheight, true, 1, xslope, length / 2, dir ? -1 : 1); Shift(outmap, x, y, outwidth, outheight, true, -1, 0 - xslope, length / 2, dir ? 1 : -1); y++; if(y >= outheight) y = 0; } } } #if !defined(USE_COM_REPLACEMENT) return S_OK; #endif }
void Shiftpwm(unsigned char* pixel, unsigned char dimval) { /* Total time of this function has to be 0.02 S */ switch (dimval) { case 1: /* Leds 50% on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); break; case 2: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); break; case 3: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); break; case 4: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 5: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 6: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 7: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 8: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 9: /* Leds 50% on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 10: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 11: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 12: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 13: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 14: /* Leds fully on */ Shift(0x00); Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 15: /* Leds fully on */ Shift(0x00); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; case 16: /* Leds fully on */ Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); Shift(pixel); break; } }
void QtCalculator::pbshifttoggled(bool myboolean){ if(myboolean) Shift(); if(pbshift->isOn() && (!key_pressed)) pbshift->setOn(FALSE); }
//------------------------------------------------------------------------- PVideoFrame __stdcall MVFlow::GetFrame(int n, IScriptEnvironment* env) { PVideoFrame src = child->GetFrame(n, env); bool paritySrc = child->GetParity(n); int nref; int off = mvClip.GetDeltaFrame(); // integer offset of reference frame if ( mvClip.IsBackward() ) { nref = n + off; } else { nref = n - off; } PVideoFrame mvn = mvClip.GetFrame(n, env); mvClip.Update(mvn, env);// backward from next to current int sharp = mvClip.GetSharp(); if ( mvClip.IsUsable()) { // get reference frames PMVGroupOfFrames pRefGOF = mvCore->GetFrame(nIdx, nref); if (!pRefGOF->IsProcessed()) { PVideoFrame ref, ref2x; ref = child->GetFrame(nref, env); pRefGOF->SetParity(child->GetParity(nref)); if (usePelClipHere) ref2x= pelclip->GetFrame(nref, env); ProcessFrameIntoGroupOfFrames(&pRefGOF, &ref, &ref2x, sharp, pixelType, nHeight, nWidth, nPel, isse); } PVideoFrame dst = env->NewVideoFrame(vi); // convert to frames unsigned char *pDst[3]; int nDstPitches[3]; DstPlanes->ConvertVideoFrameToPlanes(&dst, pDst, nDstPitches); MVPlane *pPlanes[3]; pPlanes[0] = pRefGOF->GetFrame(0)->GetPlane(YPLANE); pPlanes[1] = pRefGOF->GetFrame(0)->GetPlane(UPLANE); pPlanes[2] = pRefGOF->GetFrame(0)->GetPlane(VPLANE); if (nPel>=2 ){ if (usePelClipHere) { // simply padding 2x or 4x planes PlaneCopy(pel2PlaneY + pel2OffsetY, pel2PitchY, pRefGOF->GetVFYPtr(), pRefGOF->GetVFYPitch(), nWidth*nPel, nHeight*nPel, isse); Padding::PadReferenceFrame(pel2PlaneY, pel2PitchY, nHPadding*nPel, nVPadding*nPel, nWidth*nPel, nHeight*nPel); PlaneCopy(pel2PlaneU + pel2OffsetUV, pel2PitchUV, pRefGOF->GetVFUPtr(), pRefGOF->GetVFUPitch(), nWidthUV*nPel, nHeightUV*nPel, isse); Padding::PadReferenceFrame(pel2PlaneU, pel2PitchUV, nHPaddingUV*nPel, nVPaddingUV*nPel, nWidthUV*nPel, nHeightUV*nPel); PlaneCopy(pel2PlaneV + pel2OffsetUV, pel2PitchUV, pRefGOF->GetVFVPtr(), pRefGOF->GetVFVPitch(), nWidthUV*nPel, nHeightUV*nPel, isse); Padding::PadReferenceFrame(pel2PlaneV, pel2PitchUV, nHPaddingUV*nPel, nVPaddingUV*nPel, nWidthUV*nPel, nHeightUV*nPel); } else if (nPel==2) { // merge refined planes to big single plane Merge4PlanesToBig(pel2PlaneY, pel2PitchY, pPlanes[0]->GetAbsolutePointer(0,0), pPlanes[0]->GetAbsolutePointer(1,0), pPlanes[0]->GetAbsolutePointer(0,1), pPlanes[0]->GetAbsolutePointer(1,1), pPlanes[0]->GetExtendedWidth(), pPlanes[0]->GetExtendedHeight(), pPlanes[0]->GetPitch(), isse); Merge4PlanesToBig(pel2PlaneU, pel2PitchUV, pPlanes[1]->GetAbsolutePointer(0,0), pPlanes[1]->GetAbsolutePointer(1,0), pPlanes[1]->GetAbsolutePointer(0,1), pPlanes[1]->GetAbsolutePointer(1,1), pPlanes[1]->GetExtendedWidth(), pPlanes[1]->GetExtendedHeight(), pPlanes[1]->GetPitch(), isse); Merge4PlanesToBig(pel2PlaneV, pel2PitchUV, pPlanes[2]->GetAbsolutePointer(0,0), pPlanes[2]->GetAbsolutePointer(1,0), pPlanes[2]->GetAbsolutePointer(0,1), pPlanes[2]->GetAbsolutePointer(1,1), pPlanes[2]->GetExtendedWidth(), pPlanes[2]->GetExtendedHeight(), pPlanes[2]->GetPitch(), isse); } else if (nPel==4) { // merge refined planes to big single plane Merge16PlanesToBig(pel2PlaneY, pel2PitchY, pPlanes[0]->GetAbsolutePointer(0,0), pPlanes[0]->GetAbsolutePointer(1,0), pPlanes[0]->GetAbsolutePointer(2,0), pPlanes[0]->GetAbsolutePointer(3,0), pPlanes[0]->GetAbsolutePointer(1,0), pPlanes[0]->GetAbsolutePointer(1,1), pPlanes[0]->GetAbsolutePointer(1,2), pPlanes[0]->GetAbsolutePointer(1,3), pPlanes[0]->GetAbsolutePointer(2,0), pPlanes[0]->GetAbsolutePointer(2,1), pPlanes[0]->GetAbsolutePointer(2,2), pPlanes[0]->GetAbsolutePointer(2,3), pPlanes[0]->GetAbsolutePointer(3,0), pPlanes[0]->GetAbsolutePointer(3,1), pPlanes[0]->GetAbsolutePointer(3,2), pPlanes[0]->GetAbsolutePointer(3,3), pPlanes[0]->GetExtendedWidth(), pPlanes[0]->GetExtendedHeight(), pPlanes[0]->GetPitch(), isse); Merge16PlanesToBig(pel2PlaneU, pel2PitchUV, pPlanes[1]->GetAbsolutePointer(0,0), pPlanes[1]->GetAbsolutePointer(1,0), pPlanes[1]->GetAbsolutePointer(2,0), pPlanes[1]->GetAbsolutePointer(3,0), pPlanes[1]->GetAbsolutePointer(1,0), pPlanes[1]->GetAbsolutePointer(1,1), pPlanes[1]->GetAbsolutePointer(1,2), pPlanes[1]->GetAbsolutePointer(1,3), pPlanes[1]->GetAbsolutePointer(2,0), pPlanes[1]->GetAbsolutePointer(2,1), pPlanes[1]->GetAbsolutePointer(2,2), pPlanes[1]->GetAbsolutePointer(2,3), pPlanes[1]->GetAbsolutePointer(3,0), pPlanes[1]->GetAbsolutePointer(3,1), pPlanes[1]->GetAbsolutePointer(3,2), pPlanes[1]->GetAbsolutePointer(3,3), pPlanes[1]->GetExtendedWidth(), pPlanes[1]->GetExtendedHeight(), pPlanes[1]->GetPitch(), isse); Merge16PlanesToBig(pel2PlaneV, pel2PitchUV, pPlanes[2]->GetAbsolutePointer(0,0), pPlanes[2]->GetAbsolutePointer(1,0), pPlanes[2]->GetAbsolutePointer(2,0), pPlanes[2]->GetAbsolutePointer(3,0), pPlanes[2]->GetAbsolutePointer(1,0), pPlanes[2]->GetAbsolutePointer(1,1), pPlanes[2]->GetAbsolutePointer(1,2), pPlanes[2]->GetAbsolutePointer(1,3), pPlanes[2]->GetAbsolutePointer(2,0), pPlanes[2]->GetAbsolutePointer(2,1), pPlanes[2]->GetAbsolutePointer(2,2), pPlanes[2]->GetAbsolutePointer(2,3), pPlanes[2]->GetAbsolutePointer(3,0), pPlanes[2]->GetAbsolutePointer(3,1), pPlanes[2]->GetAbsolutePointer(3,2), pPlanes[2]->GetAbsolutePointer(3,3), pPlanes[2]->GetExtendedWidth(), pPlanes[2]->GetExtendedHeight(), pPlanes[2]->GetPitch(), isse); } } // char debugbuf[100]; // for (int V=100; V<145; V++) // { // int vx1 = ((V-128)*time256)>>8; // int vx2 = ((V*time256+127)>>8) - (time256>>1); // int vx3 = ((V*time256)/256) - (time256/2); // int vx4 = ((V-128)*time256)/256; // int vx5 = V-128; // if (vx5 < 0) vx5++; // vx5 = (vx5*time256)>>8; // // sprintf(debugbuf,"MVFlow: V=%d %d %d %d %d %d", V,vx1,vx2,vx3,vx4,vx5); // OutputDebugString(debugbuf); // } // // make vector vx and vy small masks // 1. ATTENTION: vectors are assumed SHORT (|vx|, |vy| < 127) ! // 2. they will be zeroed if not // 3. added 128 to all values MakeVectorSmallMasks(mvClip, nBlkX, nBlkY, VXSmallY, nBlkXP, VYSmallY, nBlkXP); if (nBlkXP > nBlkX) // fill right { for (int j=0; j<nBlkY; j++) { VXSmallY[j*nBlkXP + nBlkX] = std::min<BYTE>(VXSmallY[j*nBlkXP + nBlkX-1],128); VYSmallY[j*nBlkXP + nBlkX] = VYSmallY[j*nBlkXP + nBlkX-1]; } } if (nBlkYP > nBlkY) // fill bottom { for (int i=0; i<nBlkXP; i++) { VXSmallY[nBlkXP*nBlkY +i] = VXSmallY[nBlkXP*(nBlkY-1) +i]; VYSmallY[nBlkXP*nBlkY +i] = std::min<BYTE>(VYSmallY[nBlkXP*(nBlkY-1) +i],128); } } int fieldShift = 0; if (fields && (nPel >= 2) && (off %2 != 0)) { fieldShift = (paritySrc && !pRefGOF->Parity()) ? (nPel/2) : ((pRefGOF->Parity() && !paritySrc) ? -(nPel/2) : 0); // vertical shift of fields for fieldbased video at finest level pel2 } for (int j=0; j<nBlkYP; j++) { for (int i=0; i<nBlkXP; i++) { VYSmallY[j*nBlkXP + i] += fieldShift; } } VectorSmallMaskYToHalfUV(VXSmallY, nBlkXP, nBlkYP, VXSmallUV, 2); VectorSmallMaskYToHalfUV(VYSmallY, nBlkXP, nBlkYP, VYSmallUV, yRatioUV); // upsize (bilinear interpolate) vector masks to fullframe size int dummyplane = PLANAR_Y; // use luma plane resizer code for all planes if we resize from luma small mask upsizer->SimpleResizeDo(VXFullY, nWidthP, nHeightP, VPitchY, VXSmallY, nBlkXP, nBlkXP, dummyplane); upsizer->SimpleResizeDo(VYFullY, nWidthP, nHeightP, VPitchY, VYSmallY, nBlkXP, nBlkXP, dummyplane); upsizerUV->SimpleResizeDo(VXFullUV, nWidthPUV, nHeightPUV, VPitchUV, VXSmallUV, nBlkXP, nBlkXP, dummyplane); upsizerUV->SimpleResizeDo(VYFullUV, nWidthPUV, nHeightPUV, VPitchUV, VYSmallUV, nBlkXP, nBlkXP, dummyplane); if (mode==0) // fetch mode { if (nPel>=2) { Fetch(pDst[0], nDstPitches[0], pel2PlaneY + pel2OffsetY, pel2PitchY, VXFullY, VPitchY, VYFullY, VPitchY, nWidth, nHeight, time256); //padded Fetch(pDst[1], nDstPitches[1], pel2PlaneU + pel2OffsetUV, pel2PitchUV, VXFullUV, VPitchUV, VYFullUV, VPitchUV, nWidthUV, nHeightUV, time256); Fetch(pDst[2], nDstPitches[2], pel2PlaneV + pel2OffsetUV, pel2PitchUV, VXFullUV, VPitchUV, VYFullUV, VPitchUV, nWidthUV, nHeightUV, time256); } else //(nPel==1) { Fetch(pDst[0], nDstPitches[0], pPlanes[0]->GetPointer(0,0), pPlanes[0]->GetPitch(), VXFullY, VPitchY, VYFullY, VPitchY, nWidth, nHeight, time256); //padded Fetch(pDst[1], nDstPitches[1], pPlanes[1]->GetPointer(0,0), pPlanes[1]->GetPitch(), VXFullUV, VPitchUV, VYFullUV, VPitchUV, nWidthUV, nHeightUV, time256); Fetch(pDst[2], nDstPitches[2], pPlanes[2]->GetPointer(0,0), pPlanes[2]->GetPitch(), VXFullUV, VPitchUV, VYFullUV, VPitchUV, nWidthUV, nHeightUV, time256); } } else if (mode==1) // shift mode { MemZoneSet(pDst[0], 0, nWidth, nHeight, 0, 0, nDstPitches[0]); MemZoneSet(pDst[1], 0, nWidthUV, nHeightUV, 0, 0, nDstPitches[1]); MemZoneSet(pDst[2], 0, nWidthUV, nHeightUV, 0, 0, nDstPitches[2]); Shift(pDst[0], nDstPitches[0], pPlanes[0]->GetPointer(0,0), pPlanes[0]->GetPitch(), VXFullY, VPitchY, VYFullY, VPitchY, nWidth, nHeight, time256); Shift(pDst[1], nDstPitches[1], pPlanes[1]->GetPointer(0,0), pPlanes[1]->GetPitch(), VXFullUV, VPitchUV, VYFullUV, VPitchUV, nWidthUV, nHeightUV, time256); Shift(pDst[2], nDstPitches[2], pPlanes[2]->GetPointer(0,0), pPlanes[2]->GetPitch(), VXFullUV, VPitchUV, VYFullUV, VPitchUV, nWidthUV, nHeightUV, time256); } // convert back from planes unsigned char *pDstYUY2 = dst->GetWritePtr(); int nDstPitchYUY2 = dst->GetPitch(); DstPlanes->YUY2FromPlanes(pDstYUY2, nDstPitchYUY2); return dst; } else { return src; } }
inline void ComputeMultiVecCommMeta( DistSymmInfo& info ) { DEBUG_ONLY(CallStackEntry cse("ComputeMultiVecCommMeta")) // Handle the interface node Int localOff = info.localNodes.back().myOff; info.distNodes[0].multiVecMeta.Empty(); info.distNodes[0].multiVecMeta.localOff = localOff; info.distNodes[0].multiVecMeta.localSize = info.localNodes.back().size; localOff += info.distNodes[0].multiVecMeta.localSize; // Handle the truly distributed nodes const int numDist = info.distNodes.size(); for( int s=1; s<numDist; ++s ) { DistSymmNodeInfo& node = info.distNodes[s]; const int teamSize = mpi::Size( node.comm ); const int teamRank = mpi::Rank( node.comm ); const DistSymmNodeInfo& childNode = info.distNodes[s-1]; const int childTeamSize = mpi::Size( childNode.comm ); const int childTeamRank = mpi::Rank( childNode.comm ); const bool inFirstTeam = ( childTeamRank == teamRank ); const bool leftIsFirst = ( childNode.onLeft==inFirstTeam ); const int leftTeamSize = ( childNode.onLeft ? childTeamSize : teamSize-childTeamSize ); const int rightTeamSize = teamSize - leftTeamSize; const int leftTeamOff = ( leftIsFirst ? 0 : rightTeamSize ); const int rightTeamOff = ( leftIsFirst ? leftTeamSize : 0 ); const std::vector<Int>& myRelInds = ( childNode.onLeft ? node.leftRelInds : node.rightRelInds ); // Fill numChildSendInds MultiVecCommMeta& commMeta = node.multiVecMeta; commMeta.Empty(); commMeta.numChildSendInds.resize( teamSize ); El::MemZero( &commMeta.numChildSendInds[0], teamSize ); const Int updateSize = childNode.lowerStruct.size(); { const Int align = childNode.size % childTeamSize; const Int shift = Shift( childTeamRank, align, childTeamSize ); const Int localHeight = Length( updateSize, shift, childTeamSize ); for( Int iChildLoc=0; iChildLoc<localHeight; ++iChildLoc ) { const Int iChild = shift + iChildLoc*childTeamSize; const int destRank = myRelInds[iChild] % teamSize; ++commMeta.numChildSendInds[destRank]; } } const Int numLeftInds = node.leftRelInds.size(); const Int numRightInds = node.rightRelInds.size(); std::vector<Int> leftInds, rightInds; for( Int i=0; i<numLeftInds; ++i ) if( node.leftRelInds[i] % teamSize == teamRank ) leftInds.push_back( i ); for( Int i=0; i<numRightInds; ++i ) if( node.rightRelInds[i] % teamSize == teamRank ) rightInds.push_back( i ); // // Compute the solve recv indices // commMeta.childRecvInds.resize( teamSize ); // Compute the recv indices for the left child const Int numLeftSolveInds = leftInds.size(); for( Int iPre=0; iPre<numLeftSolveInds; ++iPre ) { const Int iChild = leftInds[iPre]; const Int iFront = node.leftRelInds[iChild]; const Int iFrontLoc = (iFront-teamRank) / teamSize; const int childRank = (node.leftSize+iChild) % leftTeamSize; const int frontRank = leftTeamOff + childRank; commMeta.childRecvInds[frontRank].push_back(iFrontLoc); } // Compute the recv indices for the right child const Int numRightSolveInds = rightInds.size(); for( Int iPre=0; iPre<numRightSolveInds; ++iPre ) { const Int iChild = rightInds[iPre]; const Int iFront = node.rightRelInds[iChild]; const Int iFrontLoc = (iFront-teamRank) / teamSize; const int childRank = (node.rightSize+iChild) % rightTeamSize; const int frontRank = rightTeamOff + childRank; commMeta.childRecvInds[frontRank].push_back(iFrontLoc); } commMeta.localOff = localOff; commMeta.localSize = Length(node.size,teamRank,teamSize); localOff += commMeta.localSize; } }
void Set1(int i, int val) { /* Set bit i to the low bit of val. */ if ((val & 1) != 0) bits[Index(i)] |= (1 << Shift(i)); else bits[Index(i)] &= ~(1 << Shift(i)); };
inline void ApplyRowPivots ( DistMatrix<F>& A, const std::vector<int>& image, const std::vector<int>& preimage ) { const int b = image.size(); #ifndef RELEASE PushCallStack("ApplyRowPivots"); if( A.Height() < b || b != (int)preimage.size() ) throw std::logic_error ("image and preimage must be vectors of equal length that are not " "taller than A."); #endif const int localWidth = A.LocalWidth(); if( A.Height() == 0 || A.Width() == 0 ) { #ifndef RELEASE PopCallStack(); #endif return; } // Extract the relevant process grid information const Grid& g = A.Grid(); const int r = g.Height(); const int colAlignment = A.ColAlignment(); const int colShift = A.ColShift(); const int myRow = g.Row(); // Extract the send and recv counts from the image and preimage. // This process's sends may be logically partitioned into two sets: // (a) sends from rows [0,...,b-1] // (b) sends from rows [b,...] // The latter is analyzed with image, the former deduced with preimage. std::vector<int> sendCounts(r,0), recvCounts(r,0); for( int i=colShift; i<b; i+=r ) { const int sendRow = preimage[i]; const int sendTo = (colAlignment+sendRow) % r; sendCounts[sendTo] += localWidth; const int recvRow = image[i]; const int recvFrom = (colAlignment+recvRow) % r; recvCounts[recvFrom] += localWidth; } for( int i=0; i<b; ++i ) { const int sendRow = preimage[i]; if( sendRow >= b ) { const int sendTo = (colAlignment+sendRow) % r; if( sendTo == myRow ) { const int sendFrom = (colAlignment+i) % r; recvCounts[sendFrom] += localWidth; } } const int recvRow = image[i]; if( recvRow >= b ) { const int recvFrom = (colAlignment+recvRow) % r; if( recvFrom == myRow ) { const int recvTo = (colAlignment+i) % r; sendCounts[recvTo] += localWidth; } } } // Construct the send and recv displacements from the counts std::vector<int> sendDispls(r), recvDispls(r); int totalSend=0, totalRecv=0; for( int i=0; i<r; ++i ) { sendDispls[i] = totalSend; recvDispls[i] = totalRecv; totalSend += sendCounts[i]; totalRecv += recvCounts[i]; } #ifndef RELEASE if( totalSend != totalRecv ) { std::ostringstream msg; msg << "Send and recv counts do not match: (send,recv)=" << totalSend << "," << totalRecv; throw std::logic_error( msg.str().c_str() ); } #endif // Fill vectors with the send data const int ALDim = A.LocalLDim(); std::vector<F> sendData(std::max(1,totalSend)); std::vector<int> offsets(r,0); const int localHeight = LocalLength( b, colShift, r ); for( int iLocal=0; iLocal<localHeight; ++iLocal ) { const int sendRow = preimage[colShift+iLocal*r]; const int sendTo = (colAlignment+sendRow) % r; const int offset = sendDispls[sendTo]+offsets[sendTo]; const F* ABuffer = A.LocalBuffer(iLocal,0); for( int jLocal=0; jLocal<localWidth; ++jLocal ) sendData[offset+jLocal] = ABuffer[jLocal*ALDim]; offsets[sendTo] += localWidth; } for( int i=0; i<b; ++i ) { const int recvRow = image[i]; if( recvRow >= b ) { const int recvFrom = (colAlignment+recvRow) % r; if( recvFrom == myRow ) { const int recvTo = (colAlignment+i) % r; const int iLocal = (recvRow-colShift) / r; const int offset = sendDispls[recvTo]+offsets[recvTo]; const F* ABuffer = A.LocalBuffer(iLocal,0); for( int jLocal=0; jLocal<localWidth; ++jLocal ) sendData[offset+jLocal] = ABuffer[jLocal*ALDim]; offsets[recvTo] += localWidth; } } } // Communicate all pivot rows std::vector<F> recvData(std::max(1,totalRecv)); mpi::AllToAll ( &sendData[0], &sendCounts[0], &sendDispls[0], &recvData[0], &recvCounts[0], &recvDispls[0], g.ColComm() ); // Unpack the recv data for( int k=0; k<r; ++k ) { offsets[k] = 0; int thisColShift = Shift( k, colAlignment, r ); for( int i=thisColShift; i<b; i+=r ) { const int sendRow = preimage[i]; const int sendTo = (colAlignment+sendRow) % r; if( sendTo == myRow ) { const int offset = recvDispls[k]+offsets[k]; const int iLocal = (sendRow-colShift) / r; F* ABuffer = A.LocalBuffer(iLocal,0); for( int jLocal=0; jLocal<localWidth; ++jLocal ) ABuffer[jLocal*ALDim] = recvData[offset+jLocal]; offsets[k] += localWidth; } } } for( int i=0; i<b; ++i ) { const int recvRow = image[i]; if( recvRow >= b ) { const int recvTo = (colAlignment+i) % r; if( recvTo == myRow ) { const int recvFrom = (colAlignment+recvRow) % r; const int iLocal = (i-colShift) / r; const int offset = recvDispls[recvFrom]+offsets[recvFrom]; F* ABuffer = A.LocalBuffer(iLocal,0); for( int jLocal=0; jLocal<localWidth; ++jLocal ) ABuffer[jLocal*ALDim] = recvData[offset+jLocal]; offsets[recvFrom] += localWidth; } } } #ifndef RELEASE PopCallStack(); #endif }
Matrix<T, 3, 3> const Shift(Matrix<T, 3, 3> const & m, m2::Point<U> const & pt) { return Shift(m, pt.x, pt.y); }
inline void set(unsigned long i) { v[Index(i)] |= (1 << Shift(i)); }
/** * Prepares writing. Returns a buffer range which may be written. * When you are finished, call append(). */ Range Write() { Shift(); return Range(data + tail, size - tail); }
inline void clear(unsigned long i) { v[Index(i)] &= ~(1 << Shift(i)); }
int CLayerTiles::RenderProperties(CUIRect *pToolBox) { CUIRect Button; pToolBox->HSplitBottom(12.0f, pToolBox, &Button); bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty(); if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this) InGameGroup = false; if(InGameGroup) { static int s_ColclButton = 0; if(m_pEditor->DoButton_Editor(&s_ColclButton, "Game tiles", 0, &Button, 0, "Constructs game tiles from this layer")) m_pEditor->PopupSelectGametileOpInvoke(m_pEditor->UI()->MouseX(), m_pEditor->UI()->MouseY()); int Result = m_pEditor->PopupSelectGameTileOpResult(); switch(Result) { case 4: Result = TILE_FREEZE; break; case 5: Result = TILE_UNFREEZE; break; case 6: Result = TILE_DFREEZE; break; case 7: Result = TILE_DUNFREEZE; break; default: break; } if(Result > -1) { CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer; int w = min(gl->m_Width, m_Width); int h = min(gl->m_Height, m_Height); for(int y = 0; y < h; y++) for(int x = 0; x < w; x++) if(m_pTiles[y*m_Width+x].m_Index) gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR+Result; return 1; } } enum { PROP_WIDTH=0, PROP_HEIGHT, PROP_SHIFT, PROP_IMAGE, PROP_COLOR, NUM_PROPS, }; int Color = 0; Color |= m_Color.r<<24; Color |= m_Color.g<<16; Color |= m_Color.b<<8; Color |= m_Color.a; CProperty aProps[] = { {"Width", m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000}, {"Height", m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000}, {"Shift", 0, PROPTYPE_SHIFT, 0, 0}, {"Image", m_Image, PROPTYPE_IMAGE, 0, 0}, {"Color", Color, PROPTYPE_COLOR, 0, 0}, {0}, }; if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this) // remove the image and color properties if this is the game/tele/speedup/front/switch layer { aProps[3].m_pName = 0; aProps[4].m_pName = 0; } static int s_aIds[NUM_PROPS] = {0}; int NewVal = 0; int Prop = m_pEditor->DoProperties(pToolBox, aProps, s_aIds, &NewVal); if(Prop != -1) m_pEditor->m_Map.m_Modified = true; if(Prop == PROP_WIDTH && NewVal > 1) Resize(NewVal, m_Height); else if(Prop == PROP_HEIGHT && NewVal > 1) Resize(m_Width, NewVal); else if(Prop == PROP_SHIFT) Shift(NewVal); else if(Prop == PROP_IMAGE) { if (NewVal == -1) { m_TexID = -1; m_Image = -1; } else m_Image = NewVal%m_pEditor->m_Map.m_lImages.size(); } else if(Prop == PROP_COLOR) { m_Color.r = (NewVal>>24)&0xff; m_Color.g = (NewVal>>16)&0xff; m_Color.b = (NewVal>>8)&0xff; m_Color.a = NewVal&0xff; }
void DialogShiftTimes::Process(wxCommandEvent &) { int mode = selection_mode->GetSelection(); int type = time_fields->GetSelection(); bool reverse = shift_backward->GetValue(); bool by_time = shift_by_time->GetValue(); bool start = type != 2; bool end = type != 1; SubtitleSelection sel = context->selectionController->GetSelectedSet(); long shift; if (by_time) { shift = shift_time->GetTime(); if (shift == 0) { Close(); return; } } else shift_frames->GetValue().ToLong(&shift); if (reverse) shift = -shift; // Track which rows were shifted for the log int row_number = 0; int block_start = 0; json::Array shifted_blocks; for (auto line : context->ass->Line | agi::of_type<AssDialogue>()) { ++row_number; if (!sel.count(line)) { if (block_start) { json::Object block; block["start"] = block_start; block["end"] = row_number - 1; shifted_blocks.push_back(block); block_start = 0; } if (mode == 1) continue; if (mode == 2 && shifted_blocks.empty()) continue; } else if (!block_start) block_start = row_number; if (start) line->Start = Shift(line->Start, shift, by_time, agi::vfr::START); if (end) line->End = Shift(line->End, shift, by_time, agi::vfr::END); } context->ass->Commit(_("shifting"), AssFile::COMMIT_DIAG_TIME); if (block_start) { json::Object block; block["start"] = block_start; block["end"] = row_number - 1; shifted_blocks.push_back(block); } SaveHistory(shifted_blocks); Close(); }
/*! * \brief Execute a single XSVF command stored in buf */ int XsvfExec(char *buf, int size) { int rc = 0; unsigned char cmd; XsvfSetBuf(buf, size); /* Process the XSVF command */ cmd = XsvfGetCmd(); switch(cmd) { case XCOMPLETE: /* * Normal end of the XSVF buffer reached. */ break; case XTDOMASK: /* * Set the TDO mask. Length has been specified by the last XSDRSIZE command. */ XsvfReadBitString(tdoMask, drSize); break; case XRUNTEST: /* * Set the number of microseconds the device should stay in the Run-Test-Idle * state after each visit to the SDR state. */ delay = XsvfGetLong(); break; case XREPEAT: /* * Set the number of times that TDO is tested against the expected value before * the programming operation is considered a failure. */ retries = XsvfGetByte(); break; case XSDRSIZE: /* * Set the length of the next XSDR/XSDRTDO records that follow. */ drSize = (int)XsvfGetLong(); if ((drSize + 7) / 8 > MAX_BITVEC_BYTES) { rc = XE_DATAOVERFLOW; } break; case XSIR: case XSIR2: /* * Go to the Shift-IR state and shift in the TDI value. XSIR uses * a single byte for the TDI size, while XSIR2 uses two bytes. */ if(cmd == XSIR) { irSize = XsvfGetByte(); } else { irSize = XsvfGetShort(); } XsvfReadBitString(tdiVal, irSize); rc = ReShift(irSize, tdiVal, 0, 0, SHIFT_IR, endIr, delay, 0); break; case XSDRTDO: /* * Go to the Shift-DR state and shift in the TDI value; compare the expected * value against the TDO value that was shifted out. Use the TDO mask which * was generated by the last XTDOMASK command. * * The expected TDO value is re-used in successive XSDR commands. */ XsvfReadBitString(tdiVal, drSize); XsvfReadBitString(tdoExp, drSize); rc = ReShift(drSize, tdiVal, tdoExp, tdoMask, SHIFT_DR, endDr, delay, retries); break; case XSDR: /* * Go to the Shift-DR state and shift in the TDI value; compare the expected * value from the last XSDRTDO command against the TDO value that was * shifted out. Use the TDO mask which was generated by the last XTDOMASK * instruction. */ XsvfReadBitString(tdiVal, drSize); rc = ReShift(drSize, tdiVal, tdoExp, tdoMask, SHIFT_DR, endDr, delay, retries); break; case XSDRB: case XSDRC: /* * Go to the Shift-DR state and shift in the TDI value. No comparison of TDO * value with the last specified expected value is performed. */ rc = Shift(drSize, tdiVal, 0, SHIFT_DR, SHIFT_DR); break; case XSDRE: /* * Continue to stay in Shift-DR state and shift in the TDI value. At the end * of the operation, go to the state specified in the last XENDDR command. No * comparison of TDO value with the last specified expected value is performed. */ rc = Shift(drSize, tdiVal, 0, SHIFT_DR, endDr); break; case XSDRTDOB: case XSDRTDOC: /* * Go to the Shift-DR state and shift in the TDI value. Compare all bits of the * expected value against the TDO value that is shifted out. No retries are * performed. */ rc = Shift(drSize, tdiVal, tdoExp, SHIFT_DR, SHIFT_DR); break; case XSDRTDOE: /* * Continue to stay in Shift-DR state and shift in the TDI value. Compare all * bits of the expected value against the TDO value that is shifted out. At the * end of the operation, go to the state specified in the last XENDDR command. * No retries are performed. */ rc = Shift(drSize, tdiVal, tdoExp, SHIFT_DR, endDr); break; case XSTATE: /* * Immediately set the TAP controller to Test-Logic-Reset (0) or Run-Test_idle (1). */ rc = TapStateChange(XsvfGetState(TEST_LOGIC_RESET, RUN_TEST_IDLE)); break; case XENDIR: /* * Set the XSIR end state to Run-Test-Idle (0) or Pause-IR (1). */ endIr = XsvfGetState(RUN_TEST_IDLE, PAUSE_IR); break; case XENDDR: /* * Set the XSDR/XSDRTDO end state to Run-Test-Idle (0) or Pause-DR (1). */ endDr = XsvfGetState(RUN_TEST_IDLE, PAUSE_DR); break; case XSETSDRMASKS: /* * Set SDR address and data masks for interatin XSDR commands. */ XsvfReadBitString(addrMask, drSize); XsvfReadBitString(dataMask, drSize); drSize2 = BitStringOnes(drSize, dataMask); break; case XSDRINC: /* * Do iterating XSDR commands. */ XsvfReadBitString(tdiVal, drSize); rc = ReShift(drSize, tdiVal, tdoExp, tdoMask, SHIFT_DR, endDr, delay, retries); if (rc == 0) { int num = XsvfGetByte(); while(num-- && rc == 0) { XsvfReadBitString(tdiVal2, drSize2); BitStringAdd(drSize, tdiVal, addrMask); UpdateTdi(drSize, tdiVal, drSize2, tdiVal2, dataMask); rc = ReShift(drSize, tdiVal, tdoExp, tdoMask, SHIFT_DR, endDr, delay, retries); } } break; case XCOMMENT: /* * Skip comment string. */ XsvfSkipComment(); break; default: rc = XE_ILLEGALCMD; break; } /* Check for errors in the platform dependant interface. */ if(rc == 0) { rc = XsvfGetError(); } return rc; }
inline void ApplyColumnPivots ( DistMatrix<F>& A, const std::vector<int>& image, const std::vector<int>& preimage ) { const int b = image.size(); #ifndef RELEASE PushCallStack("ApplyColumnPivots"); if( A.Width() < b || b != preimage.size() ) throw std::logic_error ("image and preimage must be vectors of equal length that are not " "wider than A."); #endif const int localHeight = A.LocalHeight(); if( A.Height() == 0 || A.Width() == 0 ) { #ifndef RELEASE PopCallStack(); #endif return; } // Extract the relevant process grid information const Grid& g = A.Grid(); const int c = g.Width(); const int rowAlignment = A.RowAlignment(); const int rowShift = A.RowShift(); const int myCol = g.Col(); // Extract the send and recv counts from the image and preimage. // This process's sends may be logically partitioned into two sets: // (a) sends from rows [0,...,b-1] // (b) sends from rows [b,...] // The latter is analyzed with image, the former deduced with preimage. std::vector<int> sendCounts(c,0), recvCounts(c,0); for( int j=rowShift; j<b; j+=c ) { const int sendCol = preimage[j]; const int sendTo = (rowAlignment+sendCol) % c; sendCounts[sendTo] += localHeight; const int recvCol = image[j]; const int recvFrom = (rowAlignment+recvCol) % c; recvCounts[recvFrom] += localHeight; } for( int j=0; j<b; ++j ) { const int sendCol = preimage[j]; if( sendCol >= b ) { const int sendTo = (rowAlignment+sendCol) % c; if( sendTo == myCol ) { const int sendFrom = (rowAlignment+j) % c; recvCounts[sendFrom] += localHeight; } } const int recvCol = image[j]; if( recvCol >= b ) { const int recvFrom = (rowAlignment+recvCol) % c; if( recvFrom == myCol ) { const int recvTo = (rowAlignment+j) % c; sendCounts[recvTo] += localHeight; } } } // Construct the send and recv displacements from the counts std::vector<int> sendDispls(c), recvDispls(c); int totalSend=0, totalRecv=0; for( int i=0; i<c; ++i ) { sendDispls[i] = totalSend; recvDispls[i] = totalRecv; totalSend += sendCounts[i]; totalRecv += recvCounts[i]; } #ifndef RELEASE if( totalSend != totalRecv ) { std::ostringstream msg; msg << "Send and recv counts do not match: (send,recv)=" << totalSend << "," << totalRecv; throw std::logic_error( msg.str().c_str() ); } #endif // Fill vectors with the send data std::vector<F> sendData(std::max(1,totalSend)); std::vector<int> offsets(c,0); const int localWidth = LocalLength( b, rowShift, c ); for( int jLocal=0; jLocal<localWidth; ++jLocal ) { const int sendCol = preimage[rowShift+jLocal*c]; const int sendTo = (rowAlignment+sendCol) % c; const int offset = sendDispls[sendTo]+offsets[sendTo]; MemCopy( &sendData[offset], A.LocalBuffer(0,jLocal), localHeight ); offsets[sendTo] += localHeight; } for( int j=0; j<b; ++j ) { const int recvCol = image[j]; if( recvCol >= b ) { const int recvFrom = (rowAlignment+recvCol) % c; if( recvFrom == myCol ) { const int recvTo = (rowAlignment+j) % c; const int jLocal = (recvCol-rowShift) / c; const int offset = sendDispls[recvTo]+offsets[recvTo]; MemCopy ( &sendData[offset], A.LocalBuffer(0,jLocal), localHeight ); offsets[recvTo] += localHeight; } } } // Communicate all pivot rows std::vector<F> recvData(std::max(1,totalRecv)); mpi::AllToAll ( &sendData[0], &sendCounts[0], &sendDispls[0], &recvData[0], &recvCounts[0], &recvDispls[0], g.RowComm() ); // Unpack the recv data for( int k=0; k<c; ++k ) { offsets[k] = 0; int thisRowShift = Shift( k, rowAlignment, c ); for( int j=thisRowShift; j<b; j+=c ) { const int sendCol = preimage[j]; const int sendTo = (rowAlignment+sendCol) % c; if( sendTo == myCol ) { const int offset = recvDispls[k]+offsets[k]; const int jLocal = (sendCol-rowShift) / c; MemCopy ( A.LocalBuffer(0,jLocal), &recvData[offset], localHeight ); offsets[k] += localHeight; } } } for( int j=0; j<b; ++j ) { const int recvCol = image[j]; if( recvCol >= b ) { const int recvTo = (rowAlignment+j) % c; if( recvTo == myCol ) { const int recvFrom = (rowAlignment+recvCol) % c; const int jLocal = (j-rowShift) / c; const int offset = recvDispls[recvFrom]+offsets[recvFrom]; MemCopy ( A.LocalBuffer(0,jLocal), &recvData[offset], localHeight ); offsets[recvFrom] += localHeight; } } } #ifndef RELEASE PopCallStack(); #endif }
/* * RunCommandLine - run a command line command */ vi_rc RunCommandLine( const char *cmdl ) { int i, x, y, x2, y2; bool n1f, n2f; int tkn, flag; bool test1; linenum n1, n2; char st[FILENAME_MAX]; info *cinfo; long val; jmp_buf jmpaddr; vi_rc rc; const char *data; /* * parse command string */ tkn = TOK_INVALID; rc = ParseCommandLine( cmdl, &n1, &n1f, &n2, &n2f, &tkn, &data ); if( rc != ERR_NO_ERR ) { return( rc ); } if( !n2f ) { if( !n1f ) { n1 = n2 = CurrentPos.line; } else { n2 = n1; } } /* * process tokens */ rc = ERR_INVALID_COMMAND; test1 = n1f || n2f; switch( tkn ) { case PCL_T_ABOUT: rc = DoAboutBox(); break; case PCL_T_PUSH: rc = PushFileStackAndMsg(); break; case PCL_T_POP: rc = PopFileStack(); break; case PCL_T_EXECUTE: data = SkipLeadingSpaces( data ); if( *data != '\0' ) { key_map scr; rc = AddKeyMap( &scr, data ); if( rc != ERR_NO_ERR ) { break; } rc = RunKeyMap( &scr, 1L ); MemFree( scr.data ); } break; case PCL_T_DELETEMENU: rc = DoMenuDelete( data ); break; case PCL_T_DELETEMENUITEM: rc = DoItemDelete( data ); break; case PCL_T_ADDMENUITEM: rc = AddMenuItem( data ); break; case PCL_T_MAXIMIZE: rc = MaximizeCurrentWindow(); break; case PCL_T_MINIMIZE: rc = MinimizeCurrentWindow(); break; case PCL_T_EXITFILESONLY: if( !ExitWithPrompt( false, false ) ) { rc = ERR_EXIT_ABORTED; } else { rc = ERR_NO_ERR; } break; case PCL_T_EXITALL: if( !ExitWithPrompt( true, false ) ) { rc = ERR_EXIT_ABORTED; } else { rc = ERR_NO_ERR; } break; case PCL_T_QUITALL: ExitWithVerify(); rc = ERR_NO_ERR; break; case PCL_T_KEYADD: data = SkipLeadingSpaces( data ); KeyAddString( data ); rc = ERR_NO_ERR; break; case PCL_T_UNALIAS: rc = UnAlias( data ); break; case PCL_T_UNABBREV: rc = UnAbbrev( data ); break; case PCL_T_UNMAP: case PCL_T_UNMAP_DMT: flag = MAPFLAG_MESSAGE + MAPFLAG_UNMAP; if( tkn == PCL_T_UNMAP_DMT ) { flag |= MAPFLAG_DAMMIT; } rc = MapKey( flag, data ); break; case PCL_T_EVAL: data = Expand( dataBuff, data, NULL ); i = setjmp( jmpaddr ); if( i != 0 ) { rc = (vi_rc)i; } else { StartExprParse( data, jmpaddr ); val = GetConstExpr(); ltoa( val, st, EditVars.Radix ); Message1( "%s", st ); rc = ERR_NO_ERR; } break; case PCL_T_COMPILE: case PCL_T_SOURCE: case PCL_T_LOAD: { char *tstr; srcline sline; data = GetNextWord1( data, st ); if( *st == '\0' ) { rc = ERR_NO_FILE_SPECIFIED; break; } if( tkn == PCL_T_COMPILE ) { EditFlags.CompileScript = true; if( st[0] == '-' ) { if( st[1] == 'a' || st[1] == 'A' ) { EditFlags.CompileAssignments = true; if( st[1] == 'A' ) { EditFlags.CompileAssignmentsDammit = true; } data = GetNextWord1( data, st); if( *st == '\0' ) { rc = ERR_NO_FILE_SPECIFIED; break; } } } } if( tkn == PCL_T_LOAD ) { EditFlags.LoadResidentScript = true; } sline = 0; rc = Source( st, data, &sline ); EditFlags.LoadResidentScript = false; EditFlags.CompileScript = false; EditFlags.CompileAssignments = false; EditFlags.CompileAssignmentsDammit = false; if( EditFlags.SourceScriptActive ) { LastError = rc; } if( rc > ERR_NO_ERR ) { Error( "%s on line %u of \"%s\"", GetErrorMsg( rc ), sline, st ); } else { if( rc != DO_NOT_CLEAR_MESSAGE_WINDOW ) { if( tkn != PCL_T_SOURCE ) { if( tkn == PCL_T_LOAD ) { tstr = strLoad; } else { tstr = strCompile; } Message1( "Script \"%s\" %s, %u lines generated, %d errors", st, tstr, sline, SourceErrCount ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } } } break; } case PCL_T_GENCONFIG: #ifndef __WIN__ data = GetNextWord1( data,st ); if( *st != '\0' ) { rc = GenerateConfiguration( st, true ); } else { rc = GenerateConfiguration( NULL, true ); } #else { bool temp = EditFlags.SaveConfig; EditFlags.SaveConfig = true; WriteProfile(); EditFlags.SaveConfig = temp; rc = ERR_NO_ERR; } #endif break; case PCL_T_COMPRESS: rc = CompressWhiteSpace(); break; case PCL_T_EXPAND: rc = ExpandWhiteSpace(); break; case PCL_T_SHOVE: rc = Shift( n1, n2, '>', true ); break; case PCL_T_SUCK: rc = Shift( n1, n2, '<', true ); break; case PCL_T_FILES: if( EditFlags.LineDisplay ) { rc = DisplayFileStatus(); } else { rc = EditFileFromList(); } break; case PCL_T_NEXT: rc = RotateFileForward(); break; case PCL_T_PREV: rc = RotateFileBackwards(); break; case PCL_T_HELP: rc = DoHelp( data ); break; case PCL_T_VIEW: case PCL_T_VIEW_DMT: EditFlags.ViewOnly = true; case PCL_T_EDIT: case PCL_T_EDIT_DMT: rc = EditFile( data, ( tkn == PCL_T_VIEW_DMT || tkn == PCL_T_EDIT_DMT ) ); EditFlags.ViewOnly = false; break; case PCL_T_OPEN: rc = OpenWindowOnFile( data ); break; case PCL_T_HIDE: case PCL_T_HIDE_DMT: rc = HideLineRange( n1, n2, ( tkn == PCL_T_HIDE_DMT ) ); break; case PCL_T_DELETE: rc = SetSavebufNumber( data ); if( rc != ERR_NO_ERR ) { break; } if( SelRgn.selected && !EditFlags.LineBased ) { AddSelRgnToSavebufAndDelete(); rc = ERR_NO_ERR; // @ may have turned this on - it is now definitely off SelRgn.selected = false; } else { rc = DeleteLineRange( n1, n2, SAVEBUF_FLAG ); } if( rc == ERR_NO_ERR ) { DCDisplayAllLines(); LineDeleteMessage( n1, n2 ); } break; case PCL_T_SAVEANDEXIT: data = GetNextWord1( data, st ); if( *st == '\0' ) { rc = SaveAndExit( st ); } else { rc = SaveAndExit( NULL ); } break; case PCL_T_PUT: case PCL_T_PUT_DMT: rc = SetSavebufNumber( data ); if( rc != ERR_NO_ERR ) { break; } rc = SaveAndResetFilePos( n1 ); if( rc == ERR_NO_ERR ) { if( tkn == PCL_T_PUT ) { rc = InsertSavebufAfter(); } else { rc = InsertSavebufBefore(); } RestoreCurrentFilePos(); } break; case PCL_T_YANK: rc = SetSavebufNumber( data ); if( rc != ERR_NO_ERR ) { break; } if( SelRgn.selected && !EditFlags.LineBased ) { rc = YankSelectedRegion(); // @ may have turned this on - it is now definitely off SelRgn.selected = false; } else { rc = YankLineRange( n1, n2 ); } break; case PCL_T_SUBSTITUTE: rc = Substitute( n1, n2, data ); break; case PCL_T_GLOBAL: case PCL_T_GLOBAL_DMT: if( !test1 ) { n1 = 1; rc = CFindLastLine( &n2 ); if( rc != ERR_NO_ERR ) { break; } } rc = Global( n1,n2, data, ( tkn == PCL_T_GLOBAL_DMT ) ); break; case PCL_T_WRITEQUIT: if( CurrentFile == NULL ) { rc = NextFile(); } else { CurrentFile->modified = true; data = GetNextWord1( data, st ); if( *st != '\0' ) { rc = SaveAndExit( st ); } else { rc = SaveAndExit( NULL ); } } break; case PCL_T_WRITE: case PCL_T_WRITE_DMT: data = GetNextWord1( data, st ); if( test1 ) { if( *st == '\0' ) { rc = ERR_NO_FILE_SPECIFIED; } else { rc = SaveFile( st, n1, n2, ( tkn == PCL_T_WRITE_DMT ) ); } } else { if( st[0] != '\0' ) { #ifdef __WIN__ if( st[0] == '?' && st[1] == '\0' ) { rc = SaveFileAs(); break; } else { rc = SaveFile( st, -1, -1, ( tkn == PCL_T_WRITE_DMT ) ); } #else rc = SaveFile( st, -1, -1, ( tkn == PCL_T_WRITE_DMT ) ); #endif } else { rc = SaveFile( NULL, -1, -1, ( tkn == PCL_T_WRITE_DMT ) ); if( rc == ERR_NO_ERR ) { Modified( false ); } } } break; case PCL_T_READ: rc = ReadAFile( n1, data ); break; case PCL_T_QUIT: #ifdef __WIN__ rc = CurFileExitOptionSaveChanges(); #else rc = NextFile(); #endif break; case PCL_T_QUIT_DMT: rc = NextFileDammit(); break; case PCL_T_DATE: GetDateTimeString( st ); Message1( st ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; break; case PCL_T_CD: data = GetNextWord1( data, st ); if( *st != '\0' ) { rc = SetCWD( st ); } else { rc = ERR_NO_ERR; } if( rc == ERR_NO_ERR ) { Message1( "Current directory is %s",CurrentDirectory ); } break; case PCL_T_SHELL: EVIL_SHELL: { #if defined( __NT__ ) && !defined( __WIN__ ) ExecCmd( NULL, NULL, NULL ); #else char foo[FILENAME_MAX]; strcpy( foo, Comspec ); ExecCmd( NULL, NULL, foo ); #endif DoVersion(); rc = ERR_NO_ERR; } break; case PCL_T_SYSTEM: if( n1f && n2f ) { rc = DoGenericFilter( n1, n2, data ); } else { data = SkipLeadingSpaces( data ); if( *data == '\0' ) { goto EVIL_SHELL; } ExecCmd( NULL, NULL, data ); rc = ERR_NO_ERR; } break; case PCL_T_RESIZE: rc = ResizeCurrentWindowWithKeys(); break; case PCL_T_TILE: data = GetNextWord1( data, st ); if( st[0] != '\0' ) { if( st[0] == 'v' ) { y = 1; for( x = 0, cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) { x++; } } else if( st[0] == 'h' ) { x = 1; for( y = 0, cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) { y++; } } else { x = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } else { y = atoi( st ); } } } else { x = EditVars.MaxWindowTileX; y = EditVars.MaxWindowTileY; } if( x > 0 && y > 0) { rc = WindowTile( x, y ); } break; case PCL_T_CASCADE: rc = WindowCascade(); break; case PCL_T_MOVEWIN: rc = MoveCurrentWindowWithKeys(); break; case PCL_T_TAG: data = GetNextWord1( data, st ); if( *st != '\0' ) { rc = TagHunt( st ); } break; case PCL_T_FGREP: { bool ci; data = SkipLeadingSpaces( data ); ci = EditFlags.CaseIgnore; if( data[0] == '-' ) { if( data[1] == 'c' ) { ci = false; data += 2; data = SkipLeadingSpaces( data ); rc = GetStringWithPossibleQuote( &data, st ); } else if( data[1] == 'i' ) { ci = true; data += 2; data = SkipLeadingSpaces( data ); rc = GetStringWithPossibleQuote( &data, st ); } else if( data[1] == 'f' ) { data += 2; data = SkipLeadingSpaces( data ); #ifdef __WIN__ // call fancy grep window { fancy_find *ff; /* ff will be set to point at a static fancy find struct * in the snoop module */ char snoopbuf[FILENAME_MAX]; if( !GetSnoopStringDialog( &ff ) ) { return( ERR_NO_ERR ); } strcpy( snoopbuf, ff->path ); /* assume no string means current directory */ if( strlen( snoopbuf ) && snoopbuf[strlen( snoopbuf ) - 1] != '\\' ){ strcat( snoopbuf, "\\" ); } MySprintf( st, "%s", ff->find ); strcat( snoopbuf, ff->ext ); ci = ff->case_ignore; if( !ff->use_regexp ) { //MakeExpressionNonRegular( st ); rc = DoFGREP( snoopbuf, st, ci ); } else { rc = DoEGREP( snoopbuf, st ); } break; } #endif } } else { rc = GetStringWithPossibleQuote( &data, st ); } if( rc != ERR_NO_STRING ) { rc = DoFGREP( data, st, ci ); } } break; case PCL_T_EGREP: rc = GetStringWithPossibleQuote( &data, st ); if( rc != ERR_NO_STRING ) { rc = DoEGREP( data, st ); } break; case PCL_T_SIZE: data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } x = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } y = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } x2 = atoi( st ); data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } y2 = atoi( st ); rc = CurrentWindowResize( x, y, x2, y2 ); break; case PCL_T_ECHO: data = GetNextWord1( data, st ); if( *st == '\0' ) { break; } rc = ERR_NO_ERR; if( !stricmp( st, "on" ) ) { EditFlags.EchoOn = true; break; } else if( !stricmp( st, "off" ) ) { EditFlags.EchoOn = false; break; } x = atoi( st ); data = SkipLeadingSpaces( data ); /* * FIXME: This is not good - I will definately have to * fix this code up. But right now I have to get the * editor ready for tomorrow. Brad. */ if( data[0] == '"' || data[0] == '/' ) { GetStringWithPossibleQuote( &data, st ); if( x > 2 ) { /* this is obviously a sick individual */ Error( "Invalid Echo" ); } else if( x == 1 ) { Message1( st ); } else if( x == 2 ) { Message2( st ); } // DisplayLineInWindow( MessageWindow, x, st ); } else { if( x > 2 ) { /* this is obviously a sick individual */ Error( "Invalid Echo" ); } else if( x == 1 ) { Message1( data ); } else if( x == 2 ) { Message2( data ); } // DisplayLineInWindow( MessageWindow, x, data ); } break; #ifdef VI_RCS case PCL_T_CHECKOUT: rc = ERR_NO_ERR; #ifdef __WINDOWS__ if( isOS2() ) break; // OS/2 shell returns before checkout finishes #endif if( CurrentFile != NULL ) { rc = ViRCSCheckout( rc ); } break; case PCL_T_CHECKIN: if( CurrentFile != NULL ) { rc = ViRCSCheckin( rc ); } break; #endif default: if( tkn >= 1000 ) { rc = ProcessEx( n1, n2, n2f, tkn - 1000, data ); break; } rc = TryCompileableToken( tkn, data, true ); if( rc != NOT_COMPILEABLE_TOKEN ) { break; } rc = ProcessWindow( tkn, data ); if( rc >= ERR_NO_ERR ) { break; } case TOK_INVALID: if( n1f && !n2f ) { if( !n1 ) { n1 = 1; } MemorizeCurrentContext(); rc = GoToLineNoRelCurs( n1 ); if( rc == ERR_NO_ERR ) { GoToColumnOnCurrentLine( 1 ); if( EditFlags.LineDisplay ) { MyPrintf( "%s\n", CurrentLine->data ); } } return( rc ); } rc = ERR_INVALID_COMMAND; break; } if( rc == ERR_NO_ERR ) { rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } return( rc ); } /* RunCommandLine */
void CMathParser::Parse()//{ Parses an input stream } { TokenRec FirstToken ; BOOL Accepted; Position = 0;//1 StackTop = -1; ErrorCode = 0; Accepted = FALSE; FirstToken.State = 0; FirstToken.Value = 0; Push(FirstToken); TokenType = NextToken(); do { //repeat switch(Stack[StackTop].State) { case 0: case 9: case 12: case 13: case 14: case 15: case 16: case 20: case 40 : { //begin if (TokenType == NUM) Shift(10); else if (TokenType == FUNC) Shift(11); else if (TokenType == MINUS) Shift(5); else if (TokenType == OPAREN) Shift(9); else if (TokenType == ERR) { // begin ErrorCode = MP_ErrMath; Accepted = TRUE; }// end { else if } else { //begin ErrorCode = MP_ErrExpression; Position -= TokenLen; //Dec(Position, TokenLen); }//end; { else } break; }//end; { case of } case 1 : { //begin if (TokenType == EOL) Accepted = TRUE; else if (TokenType == PLUS) Shift(12); else if (TokenType == MINUS) Shift(13); else { //begin ErrorCode = MP_ErrOperator; Position -= TokenLen; //Dec(Position, TokenLen); }//end { else } break; }//end; { case of } case 2 : { //begin if (TokenType == TIMES) Shift(14); else if (TokenType == DIVIDE) Shift(15); else Reduce(3); break; }//end; { case of } case 3 : { if( TokenType == MODU) Shift(40); else Reduce(6); break; }//end; { case of } case 4 : { //begin if (TokenType == EXPO) Shift(16); else Reduce(8); break; }//end; { case of } case 5 : { //begin if (TokenType == NUM) Shift(10); else if (TokenType = FUNC ) Shift(11); else if (TokenType = OPAREN) Shift(9); else { ErrorCode = MP_ErrExpression; Position -= TokenLen; //Dec(Position, TokenLen); }// end; { else } break; }// end; { case of } case 6 : Reduce(10); break; case 7 : Reduce(13); break; case 8 : Reduce(12); break; case 10 : Reduce(15); break; case 11 : { //begin if (TokenType == OPAREN) Shift(20); else { // begin ErrorCode = MP_ErrOpenParen; Position -= TokenLen; //Dec(Position, TokenLen); }//end; { else } break; }//end; { case of } case 17 : Reduce(9); break; case 18 : break;//raise Exception.Create('Bad token state'); break; case 19 : { //begin if (TokenType == PLUS) Shift(12); else if (TokenType == MINUS) Shift(13); else if (TokenType == CPAREN) Shift(27); else { //begin ErrorCode = MP_ErrOpCloseParen; Position -= TokenLen; //Dec(Position, TokenLen); }// end; break; }//end; { case of } case 21 : { // begin if (TokenType == TIMES) Shift(14); else if (TokenType == DIVIDE) Shift(15); else Reduce(1); break; }//end; { case of } case 22 : //begi { if (TokenType == TIMES) Shift(14); else if (TokenType == DIVIDE) Shift(15); else Reduce(2); break; }//end; { case of } case 23 : Reduce(4); break; case 24 : Reduce(5); break; case 25 : Reduce(7); break; case 26 : Reduce(11); break; case 27 : Reduce(14); break; case 28 : { if (TokenType == PLUS) Shift(12); else if (TokenType == MINUS) Shift(13); else if (TokenType == CPAREN) Shift(29); else { // begin ErrorCode = MP_ErrOpCloseParen; Position -= TokenLen; //Dec(Position, TokenLen); }// end; { else } break; }//end; { case of } case 29 : Reduce(16); break; case 80 : Reduce(100); break; } } while( !Accepted && (ErrorCode == 0));//end; { case } if (ErrorCode != 0 ) { // begin if (ErrorCode == MP_ErrBadRange ) Position -= TokenLen; //Dec(Position, TokenLen); //if( Assigned(FOnParseError)) //FOnParseError(Self, ErrorCode); }//end; { if } if (ErrorCode != MP_ErrSuccess )// then { // begin ParseValue = 0; return; }//end; { if } ParseValue = Stack[StackTop].Value; }//end; { Parse }
inline void ComputeFactorCommMeta ( DistSymmInfo& info, bool computeFactRecvInds ) { DEBUG_ONLY(CallStackEntry cse("ComputeFactorCommMeta")) info.distNodes[0].factorMeta.Empty(); const Int numDist = info.distNodes.size(); for( Int s=1; s<numDist; ++s ) { DistSymmNodeInfo& node = info.distNodes[s]; const int teamSize = mpi::Size( node.comm ); const DistSymmNodeInfo& childNode = info.distNodes[s-1]; // Fill factorMeta.numChildSendInds FactorCommMeta& commMeta = node.factorMeta; commMeta.Empty(); const int gridHeight = node.grid->Height(); const int gridWidth = node.grid->Width(); const int childGridHeight = childNode.grid->Height(); const int childGridWidth = childNode.grid->Width(); const int childGridRow = childNode.grid->Row(); const int childGridCol = childNode.grid->Col(); const Int mySize = childNode.size; const Int updateSize = childNode.lowerStruct.size(); commMeta.numChildSendInds.resize( teamSize ); El::MemZero( &commMeta.numChildSendInds[0], teamSize ); const std::vector<Int>& myRelInds = ( childNode.onLeft ? node.leftRelInds : node.rightRelInds ); { const Int colAlign = mySize % childGridHeight; const Int rowAlign = mySize % childGridWidth; const Int colShift = Shift( childGridRow, colAlign, childGridHeight ); const Int rowShift = Shift( childGridCol, rowAlign, childGridWidth ); const Int localHeight = Length( updateSize, colShift, childGridHeight ); const Int localWidth = Length( updateSize, rowShift, childGridWidth ); for( Int jChildLoc=0; jChildLoc<localWidth; ++jChildLoc ) { const Int jChild = rowShift + jChildLoc*childGridWidth; const int destGridCol = myRelInds[jChild] % gridWidth; Int localColShift; if( colShift > jChild ) localColShift = 0; else if( (jChild-colShift) % childGridHeight == 0 ) localColShift = (jChild-colShift)/childGridHeight; else localColShift = (jChild-colShift)/childGridHeight + 1; for( Int iChildLoc=localColShift; iChildLoc<localHeight; ++iChildLoc ) { const Int iChild = colShift + iChildLoc*childGridHeight; if( iChild >= jChild ) { const int destGridRow = myRelInds[iChild] % gridHeight; const int destRank = destGridRow+destGridCol*gridHeight; ++commMeta.numChildSendInds[destRank]; } } } } // Optionally compute the recv indices for the factorization. // This is optional since it requires a nontrivial amount of storage. if( computeFactRecvInds ) ComputeFactRecvInds( node, childNode ); } }
Grammer_Node* LRCore::Run() { auto& fout = DebugMsg::parser_dbg(); fout << "===== LRCore Run =====" << endl; script_runner->Init(); Token* t = TokenFliter(lex->Read()); LRStack.push_back(0); // 放入0号根 NodeIntStack.push_back(0); int s; while (1) { s = LRStack.back(); // printf("Stack Top: %d\n",s); char c = table->ACTION(s,t->type); switch (c) { case 's': { Shift(table->GOTO(s,t->type),t); dbg_line_vec.push_back(new DbgLine(s, t->type, 's', LRStack, NodeIntStack)); t = TokenFliter(lex->Read()); break; } case 'r': { Grammer_Node* root = ast->NewNode(); int Vn = Reduce(table->GOTO(s,t->type),root); dbg_line_vec.push_back(new DbgLine(s, t->type, 'r', LRStack, NodeIntStack)); s = LRStack.back(); // printf("Stack Top: %d, Vn:%d\n",s,Vn); Shift(table->GOTO(s,Vn),root); NodeIntStack.push_back(Vn); dbg_line_vec.push_back(new DbgLine(s, Vn, 's', LRStack, NodeIntStack)); break; } case 'a': printf("Accept!\n"); dbg_line_vec.push_back(new DbgLine(s, t->type, 'a', LRStack, NodeIntStack)); script_runner->Finished(); return ast; default: string pointer = t->debug_line; for (auto p = pointer.begin(); p != pointer.end(); ++p) { if ((p-pointer.begin()) == t->col_num) { *p = '^'; continue; } if (*p != ' ' && *p != '\t') { *p = '~'; continue; } } printf("%s\n", t->debug_line); printf("%s\n", pointer.c_str()); printf("LRCore error\n"); printf("错误的Action动作:%c\n", c); printf("目前的状态:%d\n", s); printf("Token-Type: %d\n",t->type); printf("Token: %s\n", t->pToken); printf("line: %d, %d\n",t->row_num, t->col_num); //TODO: 需要释放本层资源 return (Grammer_Node*)-1; } } }
void Initialize ( const AffineLPProblem<Matrix<Real>,Matrix<Real>>& problem, AffineLPSolution<Matrix<Real>>& solution, bool primalInit, bool dualInit, bool standardShift ) { EL_DEBUG_CSE const Int m = problem.A.Height(); const Int n = problem.A.Width(); const Int k = problem.G.Height(); if( primalInit ) { if( solution.x.Height() != n || solution.x.Width() != 1 ) LogicError("x was of the wrong size"); if( solution.s.Height() != k || solution.s.Width() != 1 ) LogicError("s was of the wrong size"); } if( dualInit ) { if( solution.y.Height() != m || solution.y.Width() != 1 ) LogicError("y was of the wrong size"); if( solution.z.Height() != k || solution.z.Width() != 1 ) LogicError("z was of the wrong size"); } if( primalInit && dualInit ) { // TODO(poulson): Perform a consistency check return; } // Form the KKT matrix // =================== Matrix<Real> J, ones; Ones( ones, k, 1 ); KKT( problem.A, problem.G, ones, ones, J ); // Factor the KKT matrix // ===================== Matrix<Real> dSub; Permutation p; LDL( J, dSub, p, false ); AffineLPResidual<Matrix<Real>> residual; Matrix<Real> u, d; Zeros( residual.dualConic, k, 1 ); if( !primalInit ) { // Minimize || G x - h ||^2, s.t. A x = b by solving // // | 0 A^T G^T | | x | | 0 | // | A 0 0 | | u | = | b |, // | G 0 -I | | -s | | h | // // where 'u' is an unused dummy variable. Zeros( residual.dualEquality, n, 1 ); residual.primalEquality = problem.b; residual.primalEquality *= -1; residual.primalConic = problem.h; residual.primalConic *= -1; KKTRHS ( residual.dualEquality, residual.primalEquality, residual.primalConic, residual.dualConic, ones, d ); ldl::SolveAfter( J, dSub, p, d, false ); ExpandCoreSolution( m, n, k, d, solution.x, u, solution.s ); solution.s *= -1; } if( !dualInit ) { // Minimize || z ||^2, s.t. A^T y + G^T z + c = 0 by solving // // | 0 A^T G^T | | u | | -c | // | A 0 0 | | y | = | 0 |, // | G 0 -I | | z | | 0 | // // where 'u' is an unused dummy variable. residual.dualEquality = problem.c; Zeros( residual.primalEquality, m, 1 ); Zeros( residual.primalConic, k, 1 ); KKTRHS ( residual.dualEquality, residual.primalEquality, residual.primalConic, residual.dualConic, ones, d ); ldl::SolveAfter( J, dSub, p, d, false ); ExpandCoreSolution( m, n, k, d, u, solution.y, solution.z ); } const Real epsilon = limits::Epsilon<Real>(); const Real sNorm = Nrm2( solution.s ); const Real zNorm = Nrm2( solution.z ); const Real gammaPrimal = Sqrt(epsilon)*Max(sNorm,Real(1)); const Real gammaDual = Sqrt(epsilon)*Max(zNorm,Real(1)); if( standardShift ) { // alpha_p := min { alpha : s + alpha*e >= 0 } // ------------------------------------------- const auto sMinPair = VectorMinLoc( solution.s ); const Real alphaPrimal = -sMinPair.value; if( alphaPrimal >= Real(0) && primalInit ) RuntimeError("initialized s was non-positive"); // alpha_d := min { alpha : z + alpha*e >= 0 } // ------------------------------------------- const auto zMinPair = VectorMinLoc( solution.z ); const Real alphaDual = -zMinPair.value; if( alphaDual >= Real(0) && dualInit ) RuntimeError("initialized z was non-positive"); if( alphaPrimal >= -gammaPrimal ) Shift( solution.s, alphaPrimal+1 ); if( alphaDual >= -gammaDual ) Shift( solution.z, alphaDual+1 ); } else { LowerClip( solution.s, gammaPrimal ); LowerClip( solution.z, gammaDual ); } }
void BoxBrowser::Draw() { if( !visible ) return; if( needToUpdateBoxes ) { needToUpdateBoxes = false; viewMode = viewFlow; Shift( 0 ); } if( viewMode == viewFlow ) { //draw text and any other 2D elements ( and leave it in 2D for the rest of the gui ) gameText->Draw(); //change to 3D context to draw boxes tiny3d_Project3D(); //draw the surface DrawSurface(); //update camera motion UpdateCamera(); for( int i = 0; i < NUM_BOXES; i++ ) { int mtxIdx = ( ( i * ANIMATION_FRAMES ) + animFrame ); if( mtxIdx >= (int)mtxBox.size() || mtxIdx < 0 ) { continue; } tiny3d_SetMatrixModelView( &mtxBox[ mtxIdx ] ); box[ i ]->DrawNoMtx(); } UpdateAnimation(); } else if( viewMode == viewZoom ) { //draw text and any other 2D elements ( and leave it in 2D for the rest of the gui ) if( bgImg2 ) { bgImg2->Draw(); } if( bgImg1 ) { //make sure this image is positioned correctly if( !bgLoaded && bgImg1->IsLoaded() ) { bgLoaded = true; //this image should either be 1000px wide or 1920 if( bgImg1->GetWidth() <= 1000 ) bgImg1->SetPosition( 124, 69, 0xfff0 );//these values seem to work for all my guitar hero & rockband games else bgImg1->SetPosition( 0, 0, 0xfff0 );//i dont have any games that fit this category, but i assume this is right } bgImg1->Draw(); } //change to 3D tiny3d_Project3D(); //update camera motion UpdateCamera(); //set matrix for zoomed box SetZoomMatrix(); //the center box hopefully is the selected one box[ NUM_BOXES / 2 ]->DrawNoMtx(); } //done in 3D mode, switch to 2D tiny3d_SetMatrixModelView( NULL ); // set matrix identity tiny3d_Project2D(); busy = false; inputIdx = 0; }
//////////////////////////////////////////////////////////////// // コマンド実行 //////////////////////////////////////////////////////////////// void cWndMon::Exec( int cmd ) { // 処理された引数の種類をチェック #define ArgvIs( x ) (argv.Type & (x)) switch( cmd ){ case MONITOR_HELP: //-------------------------------------------------------------- // help [<cmd>] // ヘルプを表示する //-------------------------------------------------------------- { int i; char *cmd = NULL; if( argv.Type != ARGV_END ){ // [cmd] cmd = argv.Str; Shift(); } if( argv.Type != ARGV_END ) ErrorMes(); // 余計な引数があればエラー if( !cmd ){ // 引数なし。全ヘルプ表示 ZCons::Printf( "help\n" ); for( i=0; i < COUNTOF(MonitorCmd); i++ ) ZCons::Printf( " %-7s %s\n", TRANS(MonitorCmd[i].cmd), TRANS(MonitorCmd[i].HelpMes) ); ZCons::Printf( QT_TRANSLATE_NOOP("PC6001VX"," 注: \"help <コマンド名>\" と入力すると 更に詳細なヘルプを表示します。\n") ); }else{ // 引数のコマンドのヘルプ表示 for( i=0; i < COUNTOF(MonitorCmd); i++ ) if( !strcmp( cmd, MonitorCmd[i].cmd ) ) break; if( i==COUNTOF(MonitorCmd) ) ErrorMes(); Help( MonitorCmd[i].Step ); } break; } case MONITOR_GO: //-------------------------------------------------------------- // go // 実行 //-------------------------------------------------------------- { if( argv.Type != ARGV_END ) ErrorMes(); vm->el->ToggleMonitor(); break; } case MONITOR_TRACE: //-------------------------------------------------------------- // trace <step> // trace #<step> // 指定したステップ分処理が変わるまで実行 //-------------------------------------------------------------- { int step = 1; if( argv.Type != ARGV_END ){ if ( ArgvIs( ARGV_SIZE ) ) step = argv.Val; // [<step>] else if( ArgvIs( ARGV_NUM ) ) step = argv.Val; // [#<step>] else ErrorMes(); Shift(); } if( argv.Type != ARGV_END ) ErrorMes(); while( step-- ){ int st = 0; while( st <= 0 ){ // バスリクエスト期間をスキップ st = vm->Emu(); vm->EventUpdate( st <= 0 ? 1 : st ); // 1命令実行とイベント更新 } } // if( CheckBreakPointPC() ) set_emumode( TRACE_BP ); // else set_emumode( M_TRACE ); break; } case MONITOR_STEP: //-------------------------------------------------------------- // step // step [call] [jp] [rep] [all] // 1ステップ,実行 // CALL,DJNZ,LDIR etc のスキップも可 //-------------------------------------------------------------- { bool call = false, jp = false, rep = false; BYTE code; WORD addr; char DisCode[128]; cZ80::Register reg; int st = 0; while( argv.Type != ARGV_END ){ if( ArgvIs( ARGV_STEP ) ){ if( argv.Val == ARG_CALL ) call = true; if( argv.Val == ARG_JP ) jp = true; if( argv.Val == ARG_REP ) rep = true; if( argv.Val == ARG_ALL ) call = jp = rep = true; Shift(); }else ErrorMes(); } if( argv.Type != ARGV_END ) ErrorMes(); vm->CpumGetRegister( ® ); addr = reg.PC.W; code = vm->MemRead( addr ); if( call ){ if( code == 0xcd || // CALL nn = 11001101B ( code&0xc7 ) == 0xc4 ){ // CALL cc,nn = 11ccc100B addr += 3; } } if( jp ){ if( code == 0x10 ){ // DJNZ e = 00010000B addr += 2; } } if( rep ){ if( code == 0xed ){ // LDIR/LDDR/CPIR/CPDR etc code = vm->MemRead( addr+1 ); if( (code&0xf4) == 0xb0 ){ addr += 2; } } } vm->CpumDisasm( DisCode, addr ); ZCons::Printf( "%s\n", DisCode ); while( st <= 0 ){ // バスリクエスト期間をスキップ st = vm->Emu(); vm->EventUpdate( st <= 0 ? 1 : st ); // 1命令実行とイベント更新 } break; } case MONITOR_STEPALL: //-------------------------------------------------------------- // S // step all に同じ //-------------------------------------------------------------- { BYTE code; WORD addr; char DisCode[128]; cZ80::Register reg; int st = -1; if( argv.Type != ARGV_END ) ErrorMes(); vm->CpumGetRegister( ® ); addr = reg.PC.W; code = vm->MemRead( addr ); if( code == 0xcd || // CALL nn = 11001101B ( code&0xc7 ) == 0xc4 ){ // CALL cc,nn = 11ccc100B addr += 3; } if( code == 0x10 ){ // DJNZ e = 00010000B addr += 2; } if( code == 0xed ){ // LDIR/LDDR/CPIR/CPDR etc code = vm->MemRead( addr+1 ); if( (code&0xf4) == 0xb0 ){ addr += 2; } } vm->CpumDisasm( DisCode, addr ); ZCons::Printf( "%s\n", DisCode ); while( st <= 0 ){ // バスリクエスト期間をスキップ st = vm->Emu(); vm->EventUpdate( st <= 0 ? 1 : st ); // 1命令実行とイベント更新 } break; } case MONITOR_BREAK: //-------------------------------------------------------------- // break [PC|READ|WRITE|IN|OUT] <addr|port> [#<No>] // break CLEAR [#<No>] // break // ブレークポイントの設定/解除/表示 //-------------------------------------------------------------- { bool show = false; int action = ARG_PC; WORD addr = 0; int number = 0; if( argv.Type != ARGV_END ){ // <action> if( ArgvIs( ARGV_BREAK ) ){ action = argv.Val; Shift(); } // <addr|port> switch( action ){ case ARG_IN: case ARG_OUT: if( !ArgvIs( ARGV_PORT ) ) ErrorMes(); addr = argv.Val; Shift(); break; case ARG_PC: case ARG_READ: case ARG_WRITE: if( !ArgvIs( ARGV_ADDR ) ) ErrorMes(); addr = argv.Val; Shift(); break; } // [#<No>] if( argv.Type != ARGV_END ){ if( !ArgvIs( ARGV_SIZE ) ) ErrorMes(); if( argv.Val < 1 || argv.Val > NR_BP ) ErrorMes(); number = argv.Val - 1; Shift(); } }else{ show = true; } if( argv.Type != ARGV_END ) ErrorMes(); if( show ){ for( int i=0; i<NR_BP; i++ ){ ZCons::Printf( " #%02d ", i+1 ); addr = vm->BpGetAddr( i ); switch( vm->BpGetType( i ) ){ case BPoint::BP_NONE: ZCons::Printf( QT_TRANSLATE_NOOP("PC6001VX", "-- なし --\n") ); break; case BPoint::BP_PC: ZCons::Printf( "PC reach %04XH\n", addr&0xffff ); break; case BPoint::BP_READ: ZCons::Printf( "READ from %04XH\n", addr&0xffff ); break; case BPoint::BP_WRITE: ZCons::Printf( "WRITE to %04XH\n", addr&0xffff ); break; case BPoint::BP_IN: ZCons::Printf( "INPUT from %02XH\n", addr&0xff ); break; case BPoint::BP_OUT: ZCons::Printf( "OUTPUT to %04XH\n", addr&0xff) ; break; default: break; } } }else{ if( action == ARG_CLEAR ){ vm->BpSetType( number, BPoint::BP_NONE ); ZCons::Printf( QT_TRANSLATE_NOOP("PC6001VX", "ブレークポイント #%02d を消去します。\n"), number+1 ); }else{ const char *s = NULL; switch( action ){ case ARG_PC: vm->BpSetType( number, BPoint::BP_PC ); s = "PC : %04XH"; break; case ARG_READ: vm->BpSetType( number, BPoint::BP_READ ); s = "READ : %04XH"; break; case ARG_WRITE: vm->BpSetType( number, BPoint::BP_WRITE ); s = "WRITE : %04XH"; break; case ARG_IN: vm->BpSetType( number, BPoint::BP_IN ); s = "IN : %02XH"; break; case ARG_OUT: vm->BpSetType( number, BPoint::BP_OUT ); s = "OUT : %02XH"; break; } vm->BpSetAddr( number, addr ); ZCons::Printf( QT_TRANSLATE_NOOP("PC6001VX", "ブレークポイント #%02d を設定します。[ "),number+1 ); ZCons::Printf( s, addr ); ZCons::Printf( " ]\n" ); } } break; } case MONITOR_READ: //-------------------------------------------------------------- // read <addr> // 特定のアドレスをリード //-------------------------------------------------------------- break; case MONITOR_WRITE: //-------------------------------------------------------------- // write <addr> <data> // 特定のアドレスにライト //-------------------------------------------------------------- { if( argv.Type == ARGV_END ) ErrorMes(); // <addr> if( !ArgvIs( ARGV_ADDR )) ErrorMes(); WORD addr = argv.Val; Shift(); // <data> if( !ArgvIs( ARGV_INT )) ErrorMes(); BYTE data = argv.Val; Shift(); if( argv.Type != ARGV_END ) ErrorMes(); vm->MemWrite( addr, data ); ZCons::Printf( "WRITE memory [ %04XH ] <- %02X (= %d | %+d | ", addr, (BYTE)data, (BYTE)data, (int8_t)data ); int i,j; for( i=0, j=0x80; i<8; i++, j>>=1 ) ZCons::Printf( "%d", (data & j) ? 1 : 0 ); ZCons::Printf( "B )\n"); break; } case MONITOR_FILL: //-------------------------------------------------------------- // fill <start-addr> <end-addr> <value> // fill <start-addr> #<size> <value> // メモリを埋める //-------------------------------------------------------------- { int start, size, value; if( argv.Type == ARGV_END ) ErrorMes(); // <addr> if( !ArgvIs( ARGV_ADDR ) ) ErrorMes(); start = argv.Val; Shift(); // [<addr|#size>] if ( ArgvIs( ARGV_SIZE ) ) size = argv.Val; else if( ArgvIs( ARGV_ADDR ) ) size = argv.Val - start +1; else ErrorMes(); Shift(); // <data> if( !ArgvIs( ARGV_INT )) ErrorMes(); value = argv.Val; Shift(); if( argv.Type != ARGV_END ) ErrorMes(); for( int i=0; i<size; i++ ) vm->MemWrite( start+i, value ); break; } case MONITOR_MOVE: //-------------------------------------------------------------- // move <src-addr> <end-addr> <dist-addr> // move <src-addr> #size <dist-addr> // メモリ転送 //-------------------------------------------------------------- { int start, size, dist; if( argv.Type == ARGV_END ) ErrorMes(); // <addr> if( !ArgvIs( ARGV_ADDR ) ) ErrorMes(); start = argv.Val; Shift(); // [<addr|#size>] if ( ArgvIs( ARGV_SIZE ) ) size = argv.Val; else if( ArgvIs( ARGV_ADDR ) ) size = argv.Val - start +1; else ErrorMes(); Shift(); // <addr> if( !ArgvIs( ARGV_ADDR ) ) ErrorMes(); dist = argv.Val; Shift(); if( argv.Type != ARGV_END ) ErrorMes(); // 転送元-転送先が 重ならない if( start+size <= dist ) for( int i=0; i<size; i++ ) vm->MemWrite( dist+i, vm->MemRead( start+i ) ); // 転送元-転送先が 重なる else for( int i=size-1; i>=0; i-- ) vm->MemWrite( dist+i, vm->MemRead( start+i ) ); break; } case MONITOR_SEARCH: //-------------------------------------------------------------- // search [<value> [<start-addr> <end-addr>]] // search [<value> [<start-addr> #<size>]] // 特定の定数 (1バイト) をサーチ //-------------------------------------------------------------- break; case MONITOR_OUT: //-------------------------------------------------------------- // out <port> <data> // 特定のポートに出力 //-------------------------------------------------------------- { if( argv.Type == ARGV_END ) ErrorMes(); // <port> if( !ArgvIs( ARGV_PORT )) ErrorMes(); WORD port = argv.Val; Shift(); // <data> if( !ArgvIs( ARGV_INT )) ErrorMes(); BYTE data = argv.Val; Shift(); if( argv.Type != ARGV_END ) ErrorMes(); vm->IomOut( port, data ); ZCons::Printf( "OUT port [ %02XH ] <- %02X (= %d | %+d | ", port, (BYTE)data, (BYTE)data, (int8_t)data ); int i,j; for( i=0, j=0x80; i<8; i++, j>>=1 ) ZCons::Printf( "%d", (data & j) ? 1 : 0 ); ZCons::Printf( "B )\n"); break; } case MONITOR_LOADMEM: //-------------------------------------------------------------- // loadmem <filename> <start-addr> <end-addr> // loadmem <filename> <start-addr> #<size> // ファイルからメモリにロード //-------------------------------------------------------------- { char *fname; int start,size; FILE *fp; if( argv.Type == ARGV_END ) ErrorMes(); // <filename> if( !ArgvIs( ARGV_STR ) ) ErrorMes(); fname = argv.Str; Shift(); // <addr> if( !ArgvIs( ARGV_ADDR ) ) ErrorMes(); start = argv.Val; Shift(); // [<addr|#size>] if ( ArgvIs( ARGV_SIZE ) ) size = (argv.Val > 0xffff) ? 0xffff : argv.Val; else if( ArgvIs( ARGV_ADDR ) ) size = (argv.Val < start ) ? (0x10000 | argv.Val) - start + 1 : argv.Val - start + 1; else ErrorMes(); Shift(); if( argv.Type != ARGV_END ) ErrorMes(); if( (fp=fopen( fname, "rb" )) != NULL ){ int addr = start; for( int i=0; i<size; i++ ){ BYTE dat = fgetc( fp ); vm->MemWrite( (addr++)&0xffff, dat ); } fclose( fp ); ZCons::Printf( " Loaded [%s] -> %d bytes\n", fname, addr-start ); }else{ ZCons::SetColor( FC_RED ); ZCons::Printf( "Failed : File open error\n" ); ZCons::SetColor( FC_WHITE ); } break; } case MONITOR_SAVEMEM: //-------------------------------------------------------------- // savemem <filename> <start-addr> <end-addr> // savemem <filename> <start-addr> #<size> // メモリをファイルにセーブ //-------------------------------------------------------------- { char *fname; int start,size; FILE *fp; if( argv.Type == ARGV_END ) ErrorMes(); // <filename> if( !ArgvIs( ARGV_STR ) ) ErrorMes(); fname = argv.Str; Shift(); // <addr> if( !ArgvIs( ARGV_ADDR ) ) ErrorMes(); start = argv.Val; Shift(); // [<addr|#size>] if ( ArgvIs( ARGV_SIZE ) ) size = (argv.Val > 0xffff) ? 0xffff : argv.Val; else if( ArgvIs( ARGV_ADDR ) ) size = (argv.Val < start ) ? (0x10000 | argv.Val) - start + 1 : argv.Val - start + 1; else ErrorMes(); Shift(); if( argv.Type != ARGV_END ) ErrorMes(); if( (fp=fopen( fname, "wb" )) != NULL ){ int addr = start; for( int i=0; i<size; i++ ){ if( fputc( vm->MemRead( (addr++)&0xffff ), fp ) == EOF ){ ZCons::SetColor( FC_RED ); ZCons::Printf( "Failed : Data write error\n" ); ZCons::SetColor( FC_WHITE ); break; } } fclose( fp ); ZCons::Printf( " Saved [%s] -> %d bytes\n", fname, addr-start ); }else{ ZCons::SetColor( FC_RED ); ZCons::Printf( "Failed : File open error\n" ); ZCons::SetColor( FC_WHITE ); } break; } case MONITOR_RESET: //-------------------------------------------------------------- // reset // リセット //-------------------------------------------------------------- if( argv.Type != ARGV_END ) ErrorMes(); vm->Reset(); break; case MONITOR_REG: //-------------------------------------------------------------- // reg <name> <value> // レジスタの内容を変更 //-------------------------------------------------------------- { int re = -1, val=0, i; const char *str; cZ80::Register reg; if( argv.Type != ARGV_END ){ if( !ArgvIs( ARGV_REG )) ErrorMes(); // <name> re = argv.Val; Shift(); if( !ArgvIs( ARGV_INT )) ErrorMes(); // <value> val = argv.Val; Shift(); } if( argv.Type != ARGV_END ) ErrorMes(); vm->CpumGetRegister( ® ); switch( re ){ case ARG_AF: reg.AF.W = val; break; case ARG_BC: reg.BC.W = val; break; case ARG_DE: reg.DE.W = val; break; case ARG_HL: reg.HL.W = val; break; case ARG_IX: reg.IX.W = val; break; case ARG_IY: reg.IY.W = val; break; case ARG_SP: reg.SP.W = val; break; case ARG_PC: reg.PC.W = val; break; case ARG_AF1: reg.AF1.W = val; break; case ARG_BC1: reg.BC1.W = val; break; case ARG_DE1: reg.DE1.W = val; break; case ARG_HL1: reg.HL1.W = val; break; case ARG_I: val &= 0xff; reg.I = val; break; case ARG_R: val &= 0xff; reg.R = val; break; case ARG_IFF: if(val) val=1; reg.IFF = val; break; case ARG_IM: if(val>3) val=2; reg.IM = val; break; case ARG_HALT: if(val) val=1; reg.Halt = val; break; } vm->CpumSetRegister( ® ); for( i=0; i<COUNTOF( MonitorArgv ); i++ ) if( re == MonitorArgv[i].Val ) break; if( i == COUNTOF( MonitorArgv ) ) str = ""; else str = MonitorArgv[i].StrU; ZCons::Printf( "reg %s <- %04X\n", str, val ); break; } case MONITOR_DISASM: //-------------------------------------------------------------- // disasm [[<start-addr>][#<steps>]] // 逆アセンブル //-------------------------------------------------------------- { static int SaveDisasmAddr = -1; int i, pc; int addr = SaveDisasmAddr; int step = 16; char DisCode[128]; cZ80::Register reg; if( argv.Type != ARGV_END ){ if( ArgvIs( ARGV_ADDR )){ // [<addr>] addr = argv.Val; Shift(); } if( ArgvIs( ARGV_SIZE )){ // [#<step>] step = argv.Val; Shift(); } } if( argv.Type != ARGV_END ) ErrorMes(); vm->CpumGetRegister( ® ); if( addr == -1 ) addr = reg.PC.W; // ADDR 未指定時 pc = 0; for( i=0; i<step; i++ ){ pc += vm->CpumDisasm( DisCode, (WORD)(addr+pc) ); ZCons::Printf( "%s\n", DisCode ); } SaveDisasmAddr = ( addr + pc ) & 0xffff; break; } } }
void BoxBrowser::Update( GuiTrigger * t ) { inputIdx++; if( !visible || busy )//after responding to 1 controller, ignore all others till redraw return; switch( viewMode )//respond differently to button depending on what screen is showing { default: case viewFlow: { if( !ignoreInput ) { //shift coverflow if( t->pad.pressed & BTN_LEFT_ || t->pad.held & BTN_LEFT_ ) { if( buttonDelay ) { buttonDelay--; } else { mode = M_LEFT; buttonDelay = BUTTON_DELAY; ChangeSpeed( 1 ); } busy = true; } else if( t->pad.pressed & BTN_RIGHT_ || t->pad.held & BTN_RIGHT_ ) { if( buttonDelay ) { buttonDelay--; } else { mode = M_RIGHT; buttonDelay = BUTTON_DELAY; ChangeSpeed( 1 ); } busy = true; } //respond to left stick for movement else if( t->pad.stickL_x < 0 ) { mode = M_LEFT; if( t->pad.stickL_x < -120 ) { speed = MAX_SPEED; } else if( t->pad.stickL_x < -80 ) { speed = 4; } else if( t->pad.stickL_x < -60 ) { speed = 2; } else { speed = 1; } busy = true; } else if( t->pad.stickL_x > 0 ) { mode = M_RIGHT; if( t->pad.stickL_x > 120 ) { speed = MAX_SPEED; } else if( t->pad.stickL_x > 80 ) { speed = 4; } else if( t->pad.stickL_x > 60 ) { speed = 2; } else { speed = 1; } busy = true; } //change to zoom mode else if( t->pad.pressed & BTN_CROSS_ ) { viewMode = viewZoom; //clear cache to make sure there is room for 2 1920 x 1080 images ClearCache( false ); LoadBgImages(); speed = 0;//cancel any pending animation animFrame = 0; } //debugging memory availibility else if( t->pad.pressed & BTN_CIRCLE_ ) { RsxMem::PrintInfo( true ); } } //no button is pressed that we care about, start slowing down animation if( !busy && inputIdx == GUI_MAX_PADS ) { buttonDelay = 0; ChangeSpeed( 0 ); if( animFrame )//make sure it doesnt stop in the middle of animation { if( !speed ) speed = 1; } else { ChangeSpeed( 0 ); if( !speed ) mode = M_IDLE; } } } break; case viewZoom: { //change back to coverflow mode if( !ignoreInput ) { if( t->pad.pressed & BTN_CROSS_ ) { //if( currentSelection < 0 || currentSelection > GameList::Count() ) // return; //bool warez = Warez::LoadGame( GameList::At( currentSelection ).Path() ); //printf("warez: %u\n", warez ); //delete bigass background images to make room for more covers if( bgImg1 ) { delete bgImg1; bgImg1 = NULL; } if( bgImg2 ) { delete bgImg2; bgImg2 = NULL; } viewMode = viewFlow; } //move box left/right else if( ( ( t->pad.pressed & BTN_LEFT_ ) || ( t->pad.held & BTN_LEFT_ ) ) && zPosX > Z_POS_MIN_X ) { zPosX -= POS_DELTA; //printf("zPosX: %.2f zPosY: %.2f\n", zPosX, zPosY ); } else if( ( ( t->pad.pressed & BTN_RIGHT_ ) || ( t->pad.held & BTN_RIGHT_ ) ) && zPosX < Z_POS_MAX_X ) { zPosX += POS_DELTA; //printf("zPosX: %.2f zPosY: %.2f\n", zPosX, zPosY ); } //move box up/down if( ( ( t->pad.pressed & BTN_UP_ ) || ( t->pad.held & BTN_UP_ ) ) && zPosY > Z_POS_MIN_Y ) { zPosY -= POS_DELTA; //printf("zPosX: %.2f zPosY: %.2f\n", zPosX, zPosY ); } else if( ( ( t->pad.pressed & BTN_DOWN_ ) || ( t->pad.held & BTN_DOWN_ ) ) && zPosX < Z_POS_MAX_Y ) { zPosY += POS_DELTA; //printf("zPosX: %.2f zPosY: %.2f\n", zPosX, zPosY ); } //rotate on Y axis if( t->pad.stickR_x > 0 ) { zRotY -= ANGLE_DELTA; if( zRotY < Z_ROT_MIN_Y ) zRotY = 360; //printf("zRotX: %.2f zRotY: %.2f\n", zRotX, zRotY ); } else if( t->pad.stickR_x < 0 ) { zRotY += ANGLE_DELTA; if( zRotY >= Z_ROT_MAX_Y ) zRotY = 0; //printf("zRotX: %.2f zRotY: %.2f\n", zRotX, zRotY ); } //rotate on X axis if( t->pad.stickR_y < 0 ) { zRotX -= ANGLE_DELTA; if( zRotX < Z_ROT_MIN_X ) zRotX = 360; //printf("zRotX: %.2f zRotY: %.2f\n", zRotX, zRotY ); } else if( t->pad.stickR_y > 0 ) { zRotX += ANGLE_DELTA; if( zRotX >= Z_ROT_MAX_X ) zRotX = 0; //printf("zRotX: %.2f zRotY: %.2f\n", zRotX, zRotY ); } //scale if( ( ( t->pad.pressed & BTN_L2_ ) || ( t->pad.held & BTN_L2_ ) ) && zScale > Z_SCALE_MIN ) { zScale *= 0.98039f; //printf("zScale: %.2f\n", zScale ); } else if( ( ( t->pad.pressed & BTN_R2_ ) || ( t->pad.held & BTN_R2_ ) ) && zScale < Z_SCALE_MAX ) { zScale *= 1.02; //printf("zScale: %.2f\n", zScale ); } //shift to a different game if( ( t->pad.pressed & BTN_R1_ ) ) { Shift( -1 ); LoadBgImages(); } else if( ( t->pad.pressed & BTN_L1_ ) ) { Shift( 1 ); LoadBgImages(); } //reset position if( ( t->pad.pressed & BTN_TRIANGLE_ ) ) { DefaultZoom(); } } } break; } }
void InPlaceRedist( DistMatrix<F>& Z, Int rowAlign, const Base<F>* readBuffer ) { typedef Base<F> Real; const Grid& g = Z.Grid(); const Int height = Z.Height(); const Int width = Z.Width(); const Int r = g.Height(); const Int c = g.Width(); const Int p = r * c; const Int row = g.Row(); const Int col = g.Col(); const Int rowShift = Z.RowShift(); const Int colAlign = Z.ColAlign(); const Int localWidth = Length(width,g.VRRank(),rowAlign,p); const Int maxHeight = MaxLength(height,r); const Int maxWidth = MaxLength(width,p); const Int portionSize = mpi::Pad( maxHeight*maxWidth ); // Allocate our send/recv buffers vector<Real> buffer(2*r*portionSize); Real* sendBuffer = &buffer[0]; Real* recvBuffer = &buffer[r*portionSize]; // Pack EL_OUTER_PARALLEL_FOR for( Int k=0; k<r; ++k ) { Real* data = &sendBuffer[k*portionSize]; const Int thisColShift = Shift(k,colAlign,r); const Int thisLocalHeight = Length(height,thisColShift,r); EL_INNER_PARALLEL_FOR_COLLAPSE2 for( Int j=0; j<localWidth; ++j ) for( Int i=0; i<thisLocalHeight; ++i ) data[i+j*thisLocalHeight] = readBuffer[thisColShift+i*r+j*height]; } // Communicate mpi::AllToAll ( sendBuffer, portionSize, recvBuffer, portionSize, g.ColComm() ); // Unpack const Int localHeight = Length(height,row,colAlign,r); EL_OUTER_PARALLEL_FOR for( Int k=0; k<r; ++k ) { const Real* data = &recvBuffer[k*portionSize]; const Int thisRank = col+k*c; const Int thisRowShift = Shift(thisRank,rowAlign,p); const Int thisRowOffset = (thisRowShift-rowShift) / c; const Int thisLocalWidth = Length(width,thisRowShift,p); EL_INNER_PARALLEL_FOR for( Int j=0; j<thisLocalWidth; ++j ) { const Real* dataCol = &(data[j*localHeight]); Real* thisCol = (Real*)Z.Buffer(0,thisRowOffset+j*r); if( IsComplex<F>::value ) { for( Int i=0; i<localHeight; ++i ) { thisCol[2*i] = dataCol[i]; thisCol[2*i+1] = 0; } } else { MemCopy( thisCol, dataCol, localHeight ); } } } }
Shift Position::operator-(const Position& pos) const { return Shift(x - pos.x, y - pos.y, z - pos.z); }
void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) { static unsigned int t = 0; static unsigned char g = 1; static unsigned char w = 0; static unsigned char dimval = 0x01; /* interrupt service routine for Timer1 */ IFS0bits.T1IF = 0; T1CONbits.TON = 0; TMR1 = 0; T1CONbits.TON = 1; /* reset Timer 1 interrupt flag */ /* Select the LED Mode here */ if (ledmode == 1) { Shift(redleds); } if (ledmode == 2) { Shift(greenleds); } if (ledmode == 3) { Shift(blueleds); } if (ledmode == 4) { Shift(rbleds); } if (ledmode == 5) { Shift(rgleds); } if (ledmode == 6) { Shift(bgleds); } if (ledmode == 7) { Shift(rgbleds); ledmode=0; } t++; w++; /* Increase brightness every 3/8= 0.3 sec. */ if (w >= speed) { if (g == 1 ) dimval = 1; if (g == 2 ) dimval = 2; if (g == 3 ) dimval = 3; if (g == 4 ) dimval = 4; if (g == 5 ) dimval = 5; if (g == 6 ) dimval = 6; if (g == 7 ) dimval = 7; if (g == 8 ) dimval = 8; if (g == 9 ) dimval = 9; if (g == 10 ) dimval = 10; if (g == 11 ) dimval = 11; if (g == 12 ) dimval = 12; if (g == 13 ) dimval = 13; if (g == 14 ) dimval = 14; if (g == 15 ) dimval = 15; if (g == 16 ) dimval = 16; if (g == 17 ) dimval = 17; if (g == 18 ) dimval = 18; if (g == 19 ) dimval = 19; if (g == 20 ) dimval = 20; if (g == 21 ) dimval = 21; if (g == 22 ) dimval = 22; if (g == 23 ) dimval = 23; if (g == 24 ) dimval = 24; if (g == 25 ) dimval = 25; if (g == 26 ) dimval = 26; if (g == 27 ) dimval = 27; if (g == 28 ) dimval = 28; if (g == 29 ) dimval = 29; if (g == 30 ) dimval = 30; if (g == 31 ) dimval = 31; if (g == 32 ) dimval = 32; if (g == 33 ) dimval = 32; if (g == 34 ) dimval = 31; if (g == 35 ) dimval = 30; if (g == 36 ) dimval = 29; if (g == 37 ) dimval = 28; if (g == 38 ) dimval = 27; if (g == 39 ) dimval = 26; if (g == 40 ) dimval = 25; if (g == 41 ) dimval = 24; if (g == 42 ) dimval = 23; if (g == 43 ) dimval = 22; if (g == 44 ) dimval = 21; if (g == 45 ) dimval = 20; if (g == 46 ) dimval = 19; if (g == 47 ) dimval = 18; if (g == 48 ) dimval = 17; if (g == 49 ) dimval = 16; if (g == 50 ) dimval = 15; if (g == 51 ) dimval = 14; if (g == 52 ) dimval = 13; if (g == 53 ) dimval = 12; if (g == 54 ) dimval = 11; if (g == 55 ) dimval = 10; if (g == 56 ) dimval = 9; if (g == 57 ) dimval = 8; if (g == 58 ) dimval = 7; if (g == 59 ) dimval = 6; if (g == 60 ) dimval = 5; if (g == 61 ) dimval = 4; if (g == 62 ) dimval = 3; if (g == 63 ) dimval = 2; if (g == 64 ) { dimval = 1; g = 0; } g++; w = 0; } /* Every ~3 sec. new pixel values */ if (t >= 256) { Update(patt); t = 1; } if (ledmode == 0) { Shiftleds(0x0000); } }
int CLayerTiles::RenderProperties(CUIRect *pToolBox) { CUIRect Button; bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty(); if(m_pEditor->m_Map.m_pGameLayer != this) { if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size() && m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper) { static int s_AutoMapperButton = 0; pToolBox->HSplitBottom(12.0f, pToolBox, &Button); if(m_pEditor->DoButton_Editor(&s_AutoMapperButton, "Auto map", 0, &Button, 0, "")) m_pEditor->PopupSelectConfigAutoMapInvoke(m_pEditor->UI()->MouseX(), m_pEditor->UI()->MouseY()); bool Proceed = m_pEditor->PopupAutoMapProceedOrder(); if(Proceed) { if(m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->GetType() == IAutoMapper::TYPE_TILESET) { m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->Proceed(this, m_SelectedRuleSet); return 1; // only close the popup when it's a tileset } else if(m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->GetType() == IAutoMapper::TYPE_DOODADS) m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->Proceed(this, m_SelectedRuleSet, m_SelectedAmount); } } } else InGameGroup = false; if(InGameGroup) { pToolBox->HSplitBottom(2.0f, pToolBox, 0); pToolBox->HSplitBottom(12.0f, pToolBox, &Button); static int s_ColclButton = 0; if(m_pEditor->DoButton_Editor(&s_ColclButton, "Game tiles", 0, &Button, 0, "Constructs game tiles from this layer")) m_pEditor->PopupSelectGametileOpInvoke(m_pEditor->UI()->MouseX(), m_pEditor->UI()->MouseY()); int Result = m_pEditor->PopupSelectGameTileOpResult(); if(Result > -1) { CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer; int w = min(gl->m_Width, m_Width); int h = min(gl->m_Height, m_Height); for(int y = 0; y < h; y++) for(int x = 0; x < w; x++) if(m_pTiles[y*m_Width+x].m_Index) gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR+Result; return 1; } } enum { PROP_WIDTH=0, PROP_HEIGHT, PROP_SHIFT, PROP_IMAGE, PROP_COLOR, PROP_COLOR_ENV, PROP_COLOR_ENV_OFFSET, NUM_PROPS, }; int Color = 0; Color |= m_Color.r<<24; Color |= m_Color.g<<16; Color |= m_Color.b<<8; Color |= m_Color.a; CProperty aProps[] = { {"Width", m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000}, {"Height", m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000}, {"Shift", 0, PROPTYPE_SHIFT, 0, 0}, {"Image", m_Image, PROPTYPE_IMAGE, 0, 0}, {"Color", Color, PROPTYPE_COLOR, 0, 0}, {"Color Env", m_ColorEnv+1, PROPTYPE_INT_STEP, 0, m_pEditor->m_Map.m_lEnvelopes.size()+1}, {"Color TO", m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000}, {0}, }; if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image and color properties if this is the game layer { aProps[3].m_pName = 0; aProps[4].m_pName = 0; } static int s_aIds[NUM_PROPS] = {0}; int NewVal = 0; int Prop = m_pEditor->DoProperties(pToolBox, aProps, s_aIds, &NewVal); if(Prop != -1) m_pEditor->m_Map.m_Modified = true; if(Prop == PROP_WIDTH && NewVal > 1) Resize(NewVal, m_Height); else if(Prop == PROP_HEIGHT && NewVal > 1) Resize(m_Width, NewVal); else if(Prop == PROP_SHIFT) Shift(NewVal); else if(Prop == PROP_IMAGE) { if (NewVal == -1) { m_Texture.Invalidate(); m_Image = -1; } else m_Image = NewVal%m_pEditor->m_Map.m_lImages.size(); } else if(Prop == PROP_COLOR) { m_Color.r = (NewVal>>24)&0xff; m_Color.g = (NewVal>>16)&0xff; m_Color.b = (NewVal>>8)&0xff; m_Color.a = NewVal&0xff; }
void TransposeDist( const DistMatrix<T,U,V>& A, DistMatrix<T,V,U>& B ) { EL_DEBUG_CSE AssertSameGrids( A, B ); const Grid& g = B.Grid(); B.Resize( A.Height(), A.Width() ); if( !B.Participating() ) return; const Int colStrideA = A.ColStride(); const Int rowStrideA = A.RowStride(); const Int distSize = A.DistSize(); if( A.DistSize() == 1 && B.DistSize() == 1 ) { Copy( A.LockedMatrix(), B.Matrix() ); } else if( A.Width() == 1 ) { const Int height = A.Height(); const Int maxLocalHeight = MaxLength(height,distSize); const Int portionSize = mpi::Pad( maxLocalHeight ); const Int colDiff = Shift(A.DistRank(),A.ColAlign(),distSize) - Shift(B.DistRank(),B.ColAlign(),distSize); const Int sendRankB = Mod( B.DistRank()+colDiff, distSize ); const Int recvRankA = Mod( A.DistRank()-colDiff, distSize ); const Int recvRankB = (recvRankA/colStrideA)+rowStrideA*(recvRankA%colStrideA); vector<T> buffer; FastResize( buffer, (colStrideA+rowStrideA)*portionSize ); T* sendBuf = &buffer[0]; T* recvBuf = &buffer[colStrideA*portionSize]; if( A.RowRank() == A.RowAlign() ) { // Pack // TODO(poulson): Use kernel from copy::util const Int AColShift = A.ColShift(); const T* ABuf = A.LockedBuffer(); EL_PARALLEL_FOR for( Int k=0; k<rowStrideA; ++k ) { T* data = &recvBuf[k*portionSize]; const Int shift = Shift_(A.ColRank()+colStrideA*k,A.ColAlign(),distSize); const Int offset = (shift-AColShift) / colStrideA; const Int thisLocalHeight = Length_(height,shift,distSize); for( Int iLoc=0; iLoc<thisLocalHeight; ++iLoc ) data[iLoc] = ABuf[offset+iLoc*rowStrideA]; } } // (e.g., A[VC,STAR] <- A[MC,MR]) mpi::Scatter ( recvBuf, portionSize, sendBuf, portionSize, A.RowAlign(), A.RowComm() ); // (e.g., A[VR,STAR] <- A[VC,STAR]) mpi::SendRecv ( sendBuf, portionSize, sendRankB, recvBuf, portionSize, recvRankB, B.DistComm() ); // (e.g., A[MR,MC] <- A[VR,STAR]) mpi::Gather ( recvBuf, portionSize, sendBuf, portionSize, B.RowAlign(), B.RowComm() ); if( B.RowRank() == B.RowAlign() ) { // Unpack // TODO(poulson): Use kernel from copy::util T* bufB = B.Buffer(); EL_PARALLEL_FOR for( Int k=0; k<colStrideA; ++k ) { const T* data = &sendBuf[k*portionSize]; const Int shift = Shift_(B.ColRank()+rowStrideA*k,B.ColAlign(),distSize); const Int offset = (shift-B.ColShift()) / rowStrideA; const Int thisLocalHeight = Length_(height,shift,distSize); for( Int iLoc=0; iLoc<thisLocalHeight; ++iLoc ) bufB[offset+iLoc*colStrideA] = data[iLoc]; } } }
int main(){ int array[SIZE], i; for (i=0; i<SIZE; i++) array[i] = i+1; for(i=1;i<=5;i++) Shift(array,2); return 0; }