void Key7X(void) { size_t bytesRead; if (FSFileOpen("/slot0x25KeyX.bin")) { u8 slot0x25KeyX[16] = { 0 }; bytesRead = FSFileRead(&slot0x25KeyX, 16, 0); FSFileClose(); if (bytesRead != 16) { DrawDebug(0, 1, "slot0x25KeyX.bin is too small!"); } DrawDebug(0, 1, "slot0x25KeyX.bin Found!"); DrawDebug(0, 1, ""); u8 zero[16] = { 0x00 }; memcpy((u32*)0x01FFCD00, zero, 16); setup_aeskeyX(0x25, slot0x25KeyX); } else { DrawDebug(0, 1, "You can't perform firmlaunch without slot0x25KeyX.bin"); int a; while (1) { a += 1; a -= 1; } } }
void CFW_Boot(void){ //BOOT DrawClearScreenAll(); DrawDebug(0,1, "--------------- PASTA CFW LOADER ---------------"); DrawDebug(0,1, ""); DrawDebug(0,1, "Your system is %s", cfw_FWString); DrawDebug(0,1, ""); CFW_SecondStage(); }
// @breif FirmLaunch! void FirmLaunch(void) { DrawDebug(0, 1, "Preparing ARM11"); DrawDebug(0, 1, ""); //Prepare ARM11 *(uint32_t *)0x1FFFFFF8 = *(uint32_t *)(firm.arm11Ent); DrawDebug(0, 1, "Jump!"); //Jump ((void(*)())firm.arm9Ent)(); }
bool KCore::GameRender() { PreRender(); Render(); m_Timer.Render(); I_Input.Render(); DrawDebug(); PostRender(); return true; }
void error(void) { int a; DrawDebug(0, 1, "Your firm.bin is corrupted!"); while (1) { a += 1; a -= 1; } }
void BLWorld::Draw() const { m_pMap->Display(m_oCanva); m_pBot->Draw(); m_oCanva.GetParent().DrawRect(0, 0, m_oCanva.GetWidth()-1, m_oCanva.GetHeight()-1, 255, 0, 0); DrawDebug(); }
// @breif Initialize N3DS keys void KeyInit(void* source) { int i; u8 firm_key[16] = { 0 }; u8 * _source = (u8*)source; u8 firm_key_xored[16] = { 0xDE, 0x0E, 0x42, 0x0F, 0xE5, 0x75, 0x2C, 0xF0, 0x77, 0x4D, 0xA1, 0x87, 0x42, 0x33, 0xB9, 0xAA }; for (i = 0; i<16; i++) { firm_key[i] = _source[i] ^ firm_key_xored[i]; } setup_aeskeyX(0x16, firm_key); DrawDebug(0, 1, "N3DS Key Initialized!"); }
// @breif Copy and initialize FIRM void PrepareFirmLaunch(void) { DrawDebug(0, 1, "Preparing for firmlaunch"); DrawDebug(0, 1, ""); uint32_t magic = 0x4D524946; size_t bytesRead; if (key7Xneeded) Key7X(); FSFileOpen("/3ds/PastaCFW/firm.bin"); bytesRead = FSFileRead(&firm, 0x200, 0); if (bytesRead != 0x200) error(); if (firm.magic != magic) error(); FSFileRead(firm.sect[0].p, firm.sect[0].size, firm.sect[0].offset); FSFileRead(firm.sect[1].p, firm.sect[1].size, firm.sect[1].offset); FSFileRead(firm.sect[2].p, firm.sect[2].size, firm.sect[2].offset); if (cfw_FWValue == 'd') { u8 key[16] = { 0 }; FSFileRead(&key, 0x10, (firm.sect[2].offset + 0x60)); KeyInit(key); } }
void GridNavigationComponent::Update(float a_dt) { GameobjectComponent::Update(a_dt); if (m_wander) { if (!m_activePath) { GridObject* grid = m_pathfinder->GetGridObject(); if (grid) RequestPath(grid->GetRandomPositionOnGrid()); } } TraversePath(a_dt); DrawDebug(); }
void Unit::Draw() { SDL_Rect rect = {0, 0, 76, 76 }; SDL_RendererFlip flip = SDL_FLIP_NONE; if (App->sceneMap->renderUnits) { if (selected) App->render->Blit(App->entityManager->unit_base, (int)round(position.x - 32), (int)round(position.y) - 32, true, NULL); GetTextureRect(rect, flip); int positionY = (int)round(position.y - 38); App->render->Blit(texture, (int)round(position.x - 38), positionY, true, &rect, flip); } //Should be independent from scene if (App->sceneMap->renderForces) DrawDebug(); }
void GameplayScreen::Render(Game* game) { // Clear color SDL_SetRenderDrawColor(game->renderer, 0, 0, 0, 255); // black SDL_RenderClear(game->renderer); // Render each remaining pellet on the board for (std::vector<Pellet*>::iterator iter = levelManager->GetPellets().begin(); iter != levelManager->GetPellets().end(); ++iter) { (*iter)->Render(game->renderer); } // Render the player levelManager->GetPlayer()->Render(game->renderer); // Render the AI for (std::vector<Ghost*>::iterator iter = levelManager->GetGhosts().begin(); iter != levelManager->GetGhosts().end(); ++iter) { (*iter)->Render(game->renderer); } // Render the walls for (std::vector<Sprite*>::iterator iter = levelManager->GetWalls().begin(); iter != levelManager->GetWalls().end(); ++iter) { (*iter)->Render(game->renderer); } // Render the GUI elements RenderGUI(game->renderer); // Draw additional information for debugging if (isDebugging) { DrawDebug(game->renderer); } // Update the screen SDL_RenderPresent(game->renderer); }
void Game::tick(void) { debug_clear(); if (game.paused) { tickfunctions[game.paused].OnTick(); } else { // record/playback replays Replay::run(); // run scripts RunScripts(); // call the tick function for the current game mode tickfunctions[game.mode].OnTick(); } DrawDebug(); console.Draw(); }
bool NavMesher::Build() { // ******* Only for OBJ Loading **** cleanup(); const char * filepath = "../../media/models/"; if (!m_geom || !m_geom->loadMesh(filepath)) { delete m_geom; m_geom = 0; m_ctx->log(RC_LOG_ERROR, "Geom load log %s:"); } assert(m_geom); if (!m_geom || !m_geom->getMesh()) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified."); return false; } if(m_geom->getMesh()->getTriCount() <= 0 || m_geom->getMesh()->getVertCount()<=0) Ogre::Exception(0,Ogre::String("Bad verts or Triangle count. Verts: "+ StringConverter::toString( m_geom->getMesh()->getVertCount()) + "/n" + "Triangles :" +StringConverter::toString(m_geom->getMesh()->getTriCount())),"NavMesher::Build"); //reset timer Ogre::Timer tm; tm.reset(); unsigned long stime = tm.getMicroseconds(); //clear existing Clear(); // ******* Only for OBJ Loading **** const float* bmin = m_geom->getMeshBoundsMin(); const float* bmax = m_geom->getMeshBoundsMax(); const float* verts = m_geom->getMesh()->getVerts(); const int nverts = m_geom->getMesh()->getVertCount(); const int *tris = m_geom->getMesh()->getTris(); const int ntris = m_geom->getMesh()->getTriCount(); if(sizeof(tris) <= 0 || ntris <= 0) { return false; } // // Step 1. Initialize build config. // // Init build configuration from GUI memset(&m_cfg, 0, sizeof(m_cfg)); m_cfg.cs = m_cellSize; m_cfg.ch = m_cellHeight; m_cfg.walkableSlopeAngle = m_agentMaxSlope; m_cfg.walkableHeight = (int)ceilf(m_agentHeight / m_cfg.ch); m_cfg.walkableClimb = (int)floorf(m_agentMaxClimb / m_cfg.ch); m_cfg.walkableRadius = (int)ceilf(m_agentRadius / m_cfg.cs); m_cfg.maxEdgeLen = (int)(m_edgeMaxLen / m_cellSize); m_cfg.maxSimplificationError = m_edgeMaxError; m_cfg.minRegionArea = (int)rcSqr(m_regionMinSize); // Note: area = size*size m_cfg.mergeRegionArea = (int)rcSqr(m_regionMergeSize); // Note: area = size*size m_cfg.maxVertsPerPoly = (int)m_vertsPerPoly; m_cfg.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist; m_cfg.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError; // Set the area where the navigation will be build. // Here the bounds of the input mesh are used, but the // area could be specified by an user defined box, etc. rcVcopy(m_cfg.bmin, bmin); rcVcopy(m_cfg.bmax, bmax); rcCalcGridSize(m_cfg.bmin, m_cfg.bmax, m_cfg.cs, &m_cfg.width, &m_cfg.height); // Reset build times gathering. m_ctx->resetTimers(); // Start the build process. m_ctx->startTimer(RC_TIMER_TOTAL); m_ctx->log(RC_LOG_PROGRESS, "Building navigation:"); m_ctx->log(RC_LOG_PROGRESS, " - %d x %d cells", m_cfg.width, m_cfg.height); m_ctx->log(RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", nverts/1000.0f, ntris/1000.0f); // // Step 2. Rasterize input polygon soup. // // Allocate voxel heightfield where we rasterize our input data to. m_solid = rcAllocHeightfield(); if (!m_solid) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'."); return false; } if (!rcCreateHeightfield(m_ctx, *m_solid, m_cfg.width, m_cfg.height, m_cfg.bmin, m_cfg.bmax, m_cfg.cs, m_cfg.ch)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); return false; } // Allocate array that can hold triangle area types. // If you have multiple meshes you need to process, allocate // and array which can hold the max number of triangles you need to process. m_triareas = new unsigned char[ntris]; if (!m_triareas) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", ntris); return false; } // Find triangles which are walkable based on their slope and rasterize them. // If your input data is multiple meshes, you can transform them here, calculate // the are type for each of the meshes and rasterize them. memset(m_triareas, 0, ntris*sizeof(unsigned char)); rcMarkWalkableTriangles(m_ctx, m_cfg.walkableSlopeAngle, verts, nverts, tris, ntris, m_triareas); rcRasterizeTriangles(m_ctx, verts, nverts, tris, m_triareas, ntris, *m_solid, m_cfg.walkableClimb); if (!m_keepInterResults) { delete [] m_triareas; m_triareas = 0; } // // Step 3. Filter walkables surfaces. // // Once all geoemtry is rasterized, we do initial pass of filtering to // remove unwanted overhangs caused by the conservative rasterization // as well as filter spans where the character cannot possibly stand. rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid); rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid); rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid); // // Step 4. Partition walkable surface to simple regions. // // Compact the heightfield so that it is faster to handle from now on. // This will result more cache coherent data as well as the neighbours // between walkable cells will be calculated. m_chf = rcAllocCompactHeightfield(); if (!m_chf) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); return false; } if (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); return false; } if (!m_keepInterResults) { rcFreeHeightField(m_solid); m_solid = 0; } // Erode the walkable area by agent radius. if (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); return false; } // (Optional) Mark areas. const ConvexVolume* vols = m_geom->getConvexVolumes(); for (int i = 0; i < m_geom->getConvexVolumeCount(); ++i) rcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_chf); if (m_monotonePartitioning) { // Partition the walkable surface into simple regions without holes. // Monotone partitioning does not need distancefield. if (!rcBuildRegionsMonotone(m_ctx, *m_chf, 0, m_cfg.minRegionArea, m_cfg.mergeRegionArea)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build regions."); return false; } } else { // Prepare for region partitioning, by calculating distance field along the walkable surface. if (!rcBuildDistanceField(m_ctx, *m_chf)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field."); return false; } // Partition the walkable surface into simple regions without holes. if (!rcBuildRegions(m_ctx, *m_chf, 0, m_cfg.minRegionArea, m_cfg.mergeRegionArea)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build regions."); return false; } } // // Step 5. Trace and simplify region contours. // // Create contours. m_cset = rcAllocContourSet(); if (!m_cset) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'."); return false; } if (!rcBuildContours(m_ctx, *m_chf, m_cfg.maxSimplificationError, m_cfg.maxEdgeLen, *m_cset)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not create contours."); return false; } // // Step 6. Build polygons mesh from contours. // // Build polygon navmesh from the contours. m_pmesh = rcAllocPolyMesh(); if (!m_pmesh) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'."); return false; } if (!rcBuildPolyMesh(m_ctx, *m_cset, m_cfg.maxVertsPerPoly, *m_pmesh)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours."); return false; } // // Step 7. Create detail mesh which allows to access approximate height on each polygon. // m_dmesh = rcAllocPolyMeshDetail(); if (!m_dmesh) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmdtl'."); return false; } if (!rcBuildPolyMeshDetail(m_ctx, *m_pmesh, *m_chf, m_cfg.detailSampleDist, m_cfg.detailSampleMaxError, *m_dmesh)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build detail mesh."); return false; } if (!m_keepInterResults) { rcFreeCompactHeightfield(m_chf); m_chf = 0; rcFreeContourSet(m_cset); m_cset = 0; } // At this point the navigation mesh data is ready, you can access it from m_pmesh. // See rcDebugDrawPolyMesh or dtCreateNavMeshData as examples how to access the data. // // (Optional) Step 8. Create Detour data from Recast poly mesh. // // The GUI may allow more max points per polygon than Detour can handle. // Only build the detour navmesh if we do not exceed the limit. unsigned char* navData = 0; int navDataSize = 0; // Update poly flags from areas. for (int i = 0; i < m_pmesh->npolys; ++i) { if (m_pmesh->areas[i] == RC_WALKABLE_AREA) m_pmesh->areas[i] = SAMPLE_POLYAREA_GROUND; if (m_pmesh->areas[i] == SAMPLE_POLYAREA_GROUND || m_pmesh->areas[i] == SAMPLE_POLYAREA_GRASS || m_pmesh->areas[i] == SAMPLE_POLYAREA_ROAD) { m_pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK; } else if (m_pmesh->areas[i] == SAMPLE_POLYAREA_WATER) { m_pmesh->flags[i] = SAMPLE_POLYFLAGS_SWIM; } else if (m_pmesh->areas[i] == SAMPLE_POLYAREA_DOOR) { m_pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK | SAMPLE_POLYFLAGS_DOOR; } } memset(&m_params, 0, sizeof(m_params)); m_params.verts = m_pmesh->verts; m_params.vertCount = m_pmesh->nverts; m_params.polys = m_pmesh->polys; m_params.polyAreas = m_pmesh->areas; m_params.polyFlags = m_pmesh->flags; m_params.polyCount = m_pmesh->npolys; m_params.nvp = m_pmesh->nvp; m_params.detailMeshes = m_dmesh->meshes; m_params.detailVerts = m_dmesh->verts; m_params.detailVertsCount = m_dmesh->nverts; m_params.detailTris = m_dmesh->tris; m_params.detailTriCount = m_dmesh->ntris; m_params.walkableHeight = m_agentHeight; m_params.walkableRadius = m_agentRadius; m_params.walkableClimb = m_agentMaxClimb; rcVcopy(m_params.bmin, m_pmesh->bmin); rcVcopy(m_params.bmax, m_pmesh->bmax); m_params.cs = m_cfg.cs; m_params.ch = m_cfg.ch; m_params.buildBvTree = true; if (!dtCreateNavMeshData(&m_params, &navData, &navDataSize)) { m_ctx->log(RC_LOG_ERROR, "Could not build Detour navmesh."); return false; } m_navMesh = dtAllocNavMesh(); if (!m_navMesh) { delete [] navData; m_ctx->log(RC_LOG_ERROR, "Could not create Detour navmesh"); return false; } m_navQuery = dtAllocNavMeshQuery(); dtStatus status = m_navQuery->init(m_navMesh, 2048); if (dtStatusFailed(status)) { m_ctx->log(RC_LOG_ERROR, "Could not init Detour navmesh query"); return false; } if (!m_navMesh->init(navData, navDataSize, true)) { delete [] navData; m_ctx->log(RC_LOG_ERROR, "Could not init Detour navmesh"); return false; } //take time stime = tm.getMicroseconds() - stime; DrawDebug(); return true; }
// @breif [Unused]Simply wait for a key, but not use its value. // @note Work like a pause. void CFW_WaitKey(void) { DrawDebug(0,1,""); DrawDebug(0,1,"Press key to continue"); HidWaitForInput(); }
void MapWindow::RenderMapWindowBg(HDC hdc, const RECT rc, const POINT &Orig, const POINT &Orig_Aircraft) { // Calculations are taking time and slow down painting of map, beware #define MULTICALC_MINROBIN 5 // minimum split #define MULTICALC_MAXROBIN 20 // max split static short multicalc_slot=0;// -1 (which becomes immediately 0) will force full loading on startup, but this is not good // because currently we are not waiting for ProgramStarted=3 // and the first scan is made while still initializing other things // TODO assign numslots with a function, based also on available CPU time short numslots=1; #if NEWSMARTZOOM static double quickdrawscale=0.0; static double delta_drawscale=1.0; #endif #if 0 extern void TestChangeRect(); TestChangeRect(); #endif if ((MapWindow::AlphaBlendSupported() && BarOpacity<100) || mode.AnyPan()) { MapWindow::ChangeDrawRect(MapRect); } else { RECT newRect={0,0,ScreenSizeX,ScreenSizeY-BottomSize}; MapWindow::ChangeDrawRect(newRect); } if (QUICKDRAW) { goto _skip_calcs; } if (NumberOfWayPoints>200) { numslots=NumberOfWayPoints/400; // keep numslots optimal if (numslots<MULTICALC_MINROBIN) numslots=MULTICALC_MINROBIN; // seconds for full scan, as this is executed at 1Hz if (numslots>MULTICALC_MAXROBIN) numslots=MULTICALC_MAXROBIN; // When waypointnumber has changed, we wont be using an exceeded multicalc_slot, which would crash the sw // In this case, we shall probably continue for the first round to calculate without going from the beginning // but this is not a problem, we are round-robin all the time here. if (++multicalc_slot>numslots) multicalc_slot=1; } else { multicalc_slot=0; // forcing full scan } // Here we calculate arrival altitude, GD etc for map waypoints. Splitting with multicalc will result in delayed // updating of visible landables, for example. The nearest pages do this separately, with their own sorting. // Basically we assume -like for nearest- that values will not change that much in the multicalc split time. // Target and tasks are recalculated in real time in any case. Nearest too. LKCalculateWaypointReachable(multicalc_slot, numslots); _skip_calcs: CalculateScreenPositionsAirspace(rc); CalculateScreenPositionsThermalSources(); // Make the glide amoeba out of the latlon points, converting them to screen // (This function is updated for supporting multimaps ) CalculateScreenPositionsGroundline(); if (PGZoomTrigger) { if(!mode.Is(Mode::MODE_PANORAMA)) { mode.Special(Mode::MODE_SPECIAL_PANORAMA, true); LastZoomTrigger=DrawInfo.Time; Message::Lock(); Message::AddMessage(1000, 3, gettext(TEXT("_@M872_"))); // LANDSCAPE ZOOM FOR 20s Message::Unlock(); #ifndef DISABLEAUDIO if (EnableSoundModes) LKSound(TEXT("LK_TONEUP.WAV")); #endif } else { // previously called, see if time has passed if ( DrawInfo.Time > (LastZoomTrigger + 20.0)) { // time has passed, lets go back LastZoomTrigger=0; // just for safety mode.Special(Mode::MODE_SPECIAL_PANORAMA, false); PGZoomTrigger=false; Message::Lock(); Message::AddMessage(1500, 3, gettext(TEXT("_@M873_"))); // BACK TO NORMAL ZOOM Message::Unlock(); #ifndef DISABLEAUDIO if (EnableSoundModes) LKSound(TEXT("LK_TONEDOWN.WAV")); #endif } } } // // "Checkpoint Charlie" // This is were we process stuff for anything else but main map. // We let the calculations run also for MapSpace modes. // But for multimaps, we can also draw some more stuff.. // We are also sent back here from next code, when we detect that // the MapSpace mode has changed from MAP to something else while we // were rendering. // QuickRedraw: // if (DONTDRAWTHEMAP) { DrawMapSpace(hdc, rc); // Is this a "shared map" environment? if (IsMultiMapShared()) { // Shared map, of course not MSN_MAP, since dontdrawthemap was checked // if (IsMultimapOverlaysText()) { DrawLook8000(hdc,rc); } if (IsMultimapOverlaysGauges()) { if (LKVarioBar) LKDrawVario(hdc,rc); if ((mode.Is(Mode::MODE_CIRCLING)) ) if (ThermalBar) DrawThermalBand(hdcDrawWindow, rc); DrawFinalGlide(hdcDrawWindow,rc); } } else { // Not in map painting environment // ex. nearest pages, but also MAPRADAR.. } // DrawBottomBar(hdc,rc); #ifdef CPUSTATS DrawCpuStats(hdc,rc); #endif #ifdef DRAWDEBUG DrawDebug(hdc,rc); #endif // no need to do SelectObject as at the bottom of function return; } // When no terrain is painted, set a background0 // Remember that in this case we have plenty of cpu time to spend for best result if (!IsMultimapTerrain() || !DerivedDrawInfo.TerrainValid || !RasterTerrain::isTerrainLoaded() ) { // display border and fill background.. SelectObject(hdc, hInvBackgroundBrush[BgMapColor]); SelectObject(hdc, GetStockObject(WHITE_PEN)); Rectangle(hdc,rc.left,rc.top,rc.right,rc.bottom); // We force LK painting black values on screen depending on the background color in use // TODO make it an array once settled // blackscreen would force everything to be painted white, instead LKTextBlack=BgMapColorTextBlack[BgMapColor]; if (BgMapColor>6 ) BlackScreen=true; else BlackScreen=false; } else { LKTextBlack=false; BlackScreen=false; } #if NEWSMARTZOOM // Copy the old background map with no overlays if (ONSMARTZOOM) { if (quickdrawscale>0) { delta_drawscale=zoom.DrawScale() / quickdrawscale; } // StartupStore(_T("... QuickDrawScale=%.2f new zoom=%.2f delta=%.2f\n"),quickdrawscale,zoom.DrawScale(),delta_drawscale); int dx=MapRect.right-MapRect.left; int dy=MapRect.bottom-MapRect.top; // notice: zoom in is always ok.. but zoom out starting from high zoom levels will make the picture // very small and unusable. We can consider to zoom out in fast zoom normally, in such cases? // // Notice 2: the delta is not yet working correctly // if (delta_drawscale>1.0) { // zoom in StretchBlt(hdcDrawWindow, 0,0, dx,dy, hdcQuickDrawWindow, (int)((dx/2) - (dx / delta_drawscale)/2), (int)((dy/2) - (dy / delta_drawscale)/2), (int)(dx / delta_drawscale), (int)(dy / delta_drawscale), SRCCOPY); } else { // zoom out StretchBlt(hdcDrawWindow, (int)((dx/2) - (dx * delta_drawscale)/2), (int)((dy/2) - (dy * delta_drawscale)/2), (int)(dx * delta_drawscale), (int)(dy * delta_drawscale), hdcQuickDrawWindow, 0,0, dx,dy, SRCCOPY); } } #endif // Logic of DONTDRAWTHEMAP is the following: // We are rendering the screen page here. If we are here, we passed Checkpoint Charlie. // So we were, at charlie, in MSM_MAP: preparing the main map stuff. // If we detect that MapSpace has CHANGED while we were doing our job here, // it means that the user has clicked meanwhile. He desires another page, so let's // reset our intentions and go back to beginning, or nearby.. // We have a new job to do, for another MapSpace, no more MAP. if (DONTDRAWTHEMAP) { goto QuickRedraw; } #if NEWSMARTZOOM if ( OFFSMARTZOOM ) { #endif bool terrainpainted=false; if ((IsMultimapTerrain() && (DerivedDrawInfo.TerrainValid) && RasterTerrain::isTerrainLoaded()) ) { // sunelevation is never used, it is still a todo in Terrain double sunelevation = 40.0; double sunazimuth=GetAzimuth(); LockTerrainDataGraphics(); if (DONTDRAWTHEMAP) { // 100318 UnlockTerrainDataGraphics(); goto QuickRedraw; } DrawTerrain(hdc, DrawRect, sunazimuth, sunelevation); terrainpainted=true; if (DONTDRAWTHEMAP) { UnlockTerrainDataGraphics(); goto QuickRedraw; } if (!QUICKDRAW) { // SHADED terrain unreachable, aka glide amoeba. This is not the outlined perimeter! #ifdef GTL2 if (((FinalGlideTerrain == 2) || (FinalGlideTerrain == 4)) && DerivedDrawInfo.TerrainValid) { #else if ((FinalGlideTerrain==2) && DerivedDrawInfo.TerrainValid) { #endif DrawTerrainAbove(hdc, DrawRect); } } UnlockTerrainDataGraphics(); } #if NEWSMARTZOOM } #endif // // REMINDER: WE ARE IN MAIN MAP HERE: MSM_MAP ONLY, OR PANNING MODE! // MAPSPACEMODE CAN STILL CHANGE, DUE TO USER INPUT. BUT WE GOT HERE IN // EITHER PAN OR MSM_MAP. // if (DONTDRAWTHEMAP) { goto QuickRedraw; } if (IsMultimapTopology()) { DrawTopology(hdc, DrawRect); } else { // If no topology wanted, but terrain painted, we paint only water stuff if (terrainpainted) DrawTopology(hdc, DrawRect,true); } #if 0 StartupStore(_T("... Experimental1=%.0f\n"),Experimental1); StartupStore(_T("... Experimental2=%.0f\n"),Experimental2); Experimental1=0.0; Experimental2=0.0; #endif // Topology labels are printed first, using OLD wps positions from previous run! // Reset for topology labels decluttering engine occurs also in another place here! ResetLabelDeclutter(); if (Flags_DrawTask && ValidTaskPoint(ActiveWayPoint) && ValidTaskPoint(1)) { DrawTaskAAT(hdc, DrawRect); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } if (IsMultimapAirspace()) { if ( (GetAirSpaceFillType() == asp_fill_ablend_full) || (GetAirSpaceFillType() == asp_fill_ablend_borders) ) DrawTptAirSpace(hdc, rc); else DrawAirSpace(hdc, rc); // full screen, to hide clipping effect on low border } if (DONTDRAWTHEMAP) { goto QuickRedraw; } // In QUICKDRAW dont draw trail, thermals, glide terrain if (QUICKDRAW) goto _skip_stuff; if(TrailActive) { // NEED REWRITING LKDrawTrail(hdc, Orig_Aircraft, DrawRect); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } DrawThermalEstimate(hdc, DrawRect); if (OvertargetMode==OVT_THER) DrawThermalEstimateMultitarget(hdc, DrawRect); // draw red cross on glide through terrain marker if (FinalGlideTerrain && DerivedDrawInfo.TerrainValid) { DrawGlideThroughTerrain(hdc, DrawRect); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } _skip_stuff: if (IsMultimapAirspace() && AirspaceWarningMapLabels) { DrawAirspaceLabels(hdc, DrawRect, Orig_Aircraft); if (DONTDRAWTHEMAP) { // 100319 goto QuickRedraw; } } if (IsMultimapWaypoints()) { DrawWaypointsNew(hdc,DrawRect); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } if (Flags_DrawTask && ValidTaskPoint(ActiveWayPoint) && ValidTaskPoint(1)) { DrawTask(hdc, DrawRect, Orig_Aircraft); } // FAI optimizer does not depend on tasks, being based on trace if (Flags_DrawFAI) DrawFAIOptimizer(hdc, DrawRect, Orig_Aircraft); // In QUICKDRAW do not paint other useless stuff if (QUICKDRAW) { if (extGPSCONNECT) DrawBearing(hdc, DrawRect); goto _skip_2; } // --------------------------------------------------- DrawTeammate(hdc, rc); if (extGPSCONNECT) { DrawBestCruiseTrack(hdc, Orig_Aircraft); DrawBearing(hdc, DrawRect); } // draw wind vector at aircraft if (NOTANYPAN) { DrawWindAtAircraft2(hdc, Orig_Aircraft, DrawRect); } else if (mode.Is(Mode::MODE_TARGET_PAN)) { DrawWindAtAircraft2(hdc, Orig, rc); } #if NEWSMARTZOOM // Save the current rendered map before painting overlays if ( OFFSMARTZOOM ) { quickdrawscale=zoom.DrawScale(); BitBlt(hdcQuickDrawWindow, 0, 0, MapRect.right-MapRect.left, MapRect.bottom-MapRect.top, hdcDrawWindow, 0, 0, SRCCOPY); } #endif // VisualGlide drawn BEFORE lk8000 overlays if (NOTANYPAN && (VisualGlide > 0)) { DrawGlideCircle(hdc, Orig, rc); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } // Draw traffic and other specifix LK gauges LKDrawFLARMTraffic(hdc, DrawRect, Orig_Aircraft); // --------------------------------------------------- _skip_2: if (NOTANYPAN) { // REMINDER TODO let it be configurable for not circling also, as before if ((mode.Is(Mode::MODE_CIRCLING)) ) if (ThermalBar) DrawThermalBand(hdcDrawWindow, rc); // 091122 if (IsMultimapOverlaysText()) DrawLook8000(hdc,rc); DrawBottomBar(hdc,rc); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } if (IsMultimapOverlaysGauges() && (LKVarioBar && NOTANYPAN)) LKDrawVario(hdc,rc); // Draw glider or paraglider if (extGPSCONNECT) { DrawAircraft(hdc, Orig_Aircraft); } if (NOTANYPAN && !QUICKDRAW) { if (TrackBar) DrawHeading(hdc, Orig, DrawRect); } #if USETOPOMARKS // marks on top... DrawMarks(hdc, rc); #endif if (ISGAAIRCRAFT && IsMultimapOverlaysGauges() && NOTANYPAN) DrawHSI(hdc,Orig,DrawRect); if (!INPAN) { DrawMapScale(hdcDrawWindow,rc, zoom.BigZoom()); // unused BigZoom DrawCompass(hdcDrawWindow, rc, DisplayAngle); } if (IsMultimapOverlaysGauges() && NOTANYPAN) DrawFinalGlide(hdcDrawWindow,rc); #ifdef CPUSTATS DrawCpuStats(hdc,rc); #endif #ifdef DRAWDEBUG DrawDebug(hdc,rc); #endif }
void Renderer::Render() { if(m_ClearLighting) ClearLighting(); if(m_ClearAccumulationBuffer) ClearAccumulationBuffer(); CTimer frameTimer(CTimer::OGL); CTimer timer(CTimer::OGL); if(m_ProfileFrame) { std::cout << std::endl; std::cout << "Profile frame --------------- " << std::endl; std::cout << std::endl; frameTimer.Start(); timer.Start(); } SetUpRender(); if(m_ProfileFrame) timer.Stop("set up render"); if(m_ProfileFrame) timer.Start(); UpdateUniformBuffers(); if(m_ProfileFrame) timer.Stop("update ubs"); if(m_CurrentPathAntiradiance == 0 && m_CurrentPathShadowmap == 0) { m_experimentData->Init("test", "nois.data"); m_experimentData->MaxTime(450); m_globalTimer->Start(); m_resultTimer->Start(); m_glTimer->Start(); CreateGBuffer(); m_cudaGather->rebuildVisiblePointsBvh(); } if (m_confManager->GetConfVars()->drawGBufferTextures) { int border = 10; int width = (m_camera->GetWidth() - 4 * border) / 2; int height = (m_camera->GetHeight() - 4 * border) / 2; m_textureViewer->drawTexture(m_gbuffer->GetNormalTexture(), border, border, width, height); m_textureViewer->drawTexture(m_gbuffer->GetPositionTextureWS(), 3 * border + width, border, width, height); m_textureViewer->drawTexture(m_normalizeAntiradianceRenderTarget->GetTarget(2), border, 3 * border + height, width, height); m_textureViewer->drawTexture(m_depthBuffer.get(), 3 * border + width, 3 * border + height, width, height); return; } std::vector<Avpl> avpls_shadowmap; std::vector<Avpl> avpls_antiradiance; if(m_ProfileFrame) timer.Start(); //GetAVPLs(avpls_shadowmap, avpls_antiradiance); m_avplShooter->shoot(avpls_shadowmap, avpls_antiradiance, m_confManager->GetConfVars()->NumAVPLsPerFrame); m_CurrentPathAntiradiance += m_confManager->GetConfVars()->NumAVPLsPerFrame; if(m_ProfileFrame) timer.Stop("get avpls"); if(m_ProfileFrame) timer.Start(); if (m_confManager->GetConfVars()->gatherWithCuda) { if (avpls_antiradiance.size() > 0) { m_cudaGather->run(avpls_antiradiance, m_camera->GetPosition(), m_sceneProbe.get(), m_scene->getSceneExtent(), m_ProfileFrame); Add(m_gatherAntiradianceRenderTarget.get(), m_cudaRenderTarget.get()); } if(m_ProfileFrame) timer.Stop("gather"); if(m_ProfileFrame) timer.Start(); } else { Gather(avpls_shadowmap, avpls_antiradiance); if(m_ProfileFrame) timer.Stop("gather"); if(m_ProfileFrame) timer.Start(); } Normalize(m_normalizeShadowmapRenderTarget.get(), m_gatherShadowmapRenderTarget.get(), m_CurrentPathShadowmap); Normalize(m_normalizeAntiradianceRenderTarget.get(), m_gatherAntiradianceRenderTarget.get(), m_CurrentPathAntiradiance); if(m_ProfileFrame) timer.Stop("normalize"); if(m_ProfileFrame) timer.Start(); if(m_confManager->GetConfVars()->LightingMode == 2) { drawAreaLight(m_normalizeShadowmapRenderTarget.get(), glm::vec3(0.f, 0.f, 0.f)); drawAreaLight(m_normalizeAntiradianceRenderTarget.get(), glm::vec3(0.f, 0.f, 0.f)); } else { drawAreaLight(m_normalizeShadowmapRenderTarget.get(), m_scene->getAreaLight()->getRadiance()); } SetTransformToCamera(); Add(m_resultRenderTarget.get(), m_normalizeAntiradianceRenderTarget.get(), m_normalizeShadowmapRenderTarget.get()); if (m_confManager->GetConfVars()->UseDebugMode) { if (m_confManager->GetConfVars()->DrawClusterLights) { CRenderTargetLock lock(m_resultRenderTarget.get()); PointCloud pc(m_cudaGather->getVisiblePointsBvh()->centerPositions, m_cudaGather->getVisiblePointsBvh()->colors, m_ubTransform.get(), m_confManager->GetConfVars()->lightRadiusScale * m_scene->getSceneExtent() / 100.f); pc.Draw(); //m_cudaGather->getPointCloud()->Draw(); } if (m_confManager->GetConfVars()->DrawClusterAABBs) { CRenderTargetLock lock(m_resultRenderTarget.get()); AABBCloud aabb(m_cudaGather->getVisiblePointsBvh()->clusterMin, m_cudaGather->getVisiblePointsBvh()->clusterMax, m_ubTransform.get()); aabb.Draw(); //m_cudaGather->getAABBCloud()->Draw(); } if (m_confManager->GetConfVars()->DrawLights) { CRenderTargetLock lock(m_resultRenderTarget.get()); m_pointCloud->Draw(); } if (m_sceneProbe) { m_sceneProbe->draw(m_resultRenderTarget.get(), m_debugProgram.get(), m_ubTransform.get(), m_camera); m_pointCloud->Draw(); } } DrawDebug(); if(m_ProfileFrame) timer.Stop("draw debug"); m_postProcess->postprocess(m_resultRenderTarget->GetTarget(0), m_postProcessRenderTarget.get()); m_textureViewer->drawTexture(m_postProcessRenderTarget->GetTarget(0), 0, 0, m_camera->GetWidth(), m_camera->GetHeight()); m_NumAVPLs += (int)avpls_antiradiance.size(); m_NumAVPLs += (int)avpls_shadowmap.size(); if(m_ProfileFrame) timer.Start(); avpls_antiradiance.clear(); avpls_shadowmap.clear(); if(m_ProfileFrame) timer.Stop("clear avpls"); CheckExport(); m_Frame++; if(m_ProfileFrame) frameTimer.Stop("frame time"); m_ProfileFrame = false; m_FinishedDebug = true; }
void MapWindow::RenderMapWindowBg(LKSurface& Surface, const RECT& rc) { if ( (LKSurface::AlphaBlendSupported() && BarOpacity < 100) || mode.AnyPan() ) { RECT newRect = {0, 0, ScreenSizeX, ScreenSizeY}; MapWindow::ChangeDrawRect(newRect); } else { RECT newRect = {0, 0, ScreenSizeX, ScreenSizeY - BottomSize - (ScreenSizeY-MapRect.bottom)-1}; MapWindow::ChangeDrawRect(newRect); } if (QUICKDRAW) { goto _skip_calcs; } // Here we calculate arrival altitude, GD etc for map waypoints. Splitting with multicalc will result in delayed // updating of visible landables, for example. The nearest pages do this separately, with their own sorting. // Basically we assume -like for nearest- that values will not change that much in the multicalc split time. // Target and tasks are recalculated in real time in any case. Nearest too. LKCalculateWaypointReachable(false); _skip_calcs: if (PGZoomTrigger) { if (!mode.Is(Mode::MODE_PANORAMA)) { mode.Special(Mode::MODE_SPECIAL_PANORAMA, true); LastZoomTrigger = DrawInfo.Time; Message::AddMessage(1000, 3, gettext(TEXT("_@M872_"))); // LANDSCAPE ZOOM FOR 20s LKSound(TEXT("LK_TONEUP.WAV")); } else { // previously called, see if time has passed if (DrawInfo.Time > (LastZoomTrigger + 20.0)) { // time has passed, lets go back LastZoomTrigger = 0; // just for safety mode.Special(Mode::MODE_SPECIAL_PANORAMA, false); PGZoomTrigger = false; Message::AddMessage(1500, 3, gettext(TEXT("_@M873_"))); // BACK TO NORMAL ZOOM LKSound(TEXT("LK_TONEDOWN.WAV")); } } } // // "Checkpoint Charlie" // This is were we process stuff for anything else but main map. // We let the calculations run also for MapSpace modes. // But for multimaps, we can also draw some more stuff.. // We are also sent back here from next code, when we detect that // the MapSpace mode has changed from MAP to something else while we // were rendering. // QuickRedraw: // if (DONTDRAWTHEMAP) { const bool isMultimap = IsMultiMapShared(); // DrawMapSpace can change "MapSpaceMode", get this before. DrawMapSpace(Surface, rc); // Is this a "shared map" environment? if (isMultimap) { // Shared map, of course not MSN_MAP, since dontdrawthemap was checked // if (IsMultimapOverlaysGauges()) { RenderOverlayGauges(Surface, rc); } if (IsMultimapOverlaysText()) { DrawLook8000(Surface, rc); } } else { // Not in map painting environment // ex. nearest pages, but also MAPRADAR.. } // DrawBottomBar(Surface, rc); #ifdef DRAWDEBUG DrawDebug(hdc, rc); #endif // no need to do SelectObject as at the bottom of function return; } POINT Orig, Orig_Aircraft; CalculateOrigin(rc, &Orig); const ScreenProjection _Proj = CalculateScreenPositions(Orig, rc, &Orig_Aircraft); // When no terrain is painted, set a background0 // Remember that in this case we have plenty of cpu time to spend for best result if (!IsMultimapTerrain() || !DerivedDrawInfo.TerrainValid || !RasterTerrain::isTerrainLoaded()) { // We force LK painting black values on screen depending on the background color in use // TODO make it an array once settled // blackscreen would force everything to be painted white, instead LKTextBlack = BgMapColorTextBlack[BgMapColor]; if (BgMapColor > 6) BlackScreen = true; else BlackScreen = false; } else { LKTextBlack = false; BlackScreen = false; } // Logic of DONTDRAWTHEMAP is the following: // We are rendering the screen page here. If we are here, we passed Checkpoint Charlie. // So we were, at charlie, in MSM_MAP: preparing the main map stuff. // If we detect that MapSpace has CHANGED while we were doing our job here, // it means that the user has clicked meanwhile. He desires another page, so let's // reset our intentions and go back to beginning, or nearby.. // We have a new job to do, for another MapSpace, no more MAP. if (DONTDRAWTHEMAP) { goto QuickRedraw; } bool terrainpainted = false; if ((IsMultimapTerrain() && (DerivedDrawInfo.TerrainValid) && RasterTerrain::isTerrainLoaded()) ) { // sunelevation is never used, it is still a todo in Terrain double sunelevation = 40.0; double sunazimuth = GetAzimuth(); LockTerrainDataGraphics(); if (DONTDRAWTHEMAP) { // 100318 UnlockTerrainDataGraphics(); goto QuickRedraw; } if(DrawTerrain(Surface, DrawRect, _Proj, sunazimuth, sunelevation)) { terrainpainted = true; } if (DONTDRAWTHEMAP) { UnlockTerrainDataGraphics(); goto QuickRedraw; } if (!QUICKDRAW) { // SHADED terrain unreachable, aka glide amoeba. This is not the outlined perimeter! #ifdef GTL2 if (((FinalGlideTerrain == 2) || (FinalGlideTerrain == 4)) && DerivedDrawInfo.TerrainValid) { #else if ((FinalGlideTerrain == 2) && DerivedDrawInfo.TerrainValid) { #endif DrawTerrainAbove(Surface, DrawRect); } } UnlockTerrainDataGraphics(); } // // REMINDER: WE ARE IN MAIN MAP HERE: MSM_MAP ONLY, OR PANNING MODE! // MAPSPACEMODE CAN STILL CHANGE, DUE TO USER INPUT. BUT WE GOT HERE IN // EITHER PAN OR MSM_MAP. // if (DONTDRAWTHEMAP) { goto QuickRedraw; } if(!terrainpainted) { // fill background.. Surface.FillRect(&rc, hInvBackgroundBrush[BgMapColor]); } if (IsMultimapTopology()) { DrawTopology(Surface, DrawRect, _Proj); } else { // If no topology wanted, but terrain painted, we paint only water stuff if (terrainpainted) DrawTopology(Surface, DrawRect, _Proj, true); } #if 0 StartupStore(_T("... Experimental1=%.0f\n"), Experimental1); StartupStore(_T("... Experimental2=%.0f\n"), Experimental2); Experimental1 = 0.0; Experimental2 = 0.0; #endif // Topology labels are printed first, using OLD wps positions from previous run! // Reset for topology labels decluttering engine occurs also in another place here! ResetLabelDeclutter(); if ((Flags_DrawTask || TargetDialogOpen) && ValidTaskPoint(ActiveTaskPoint) && ValidTaskPoint(1)) { DrawTaskAAT(Surface, DrawRect); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } if (IsMultimapAirspace()) { DrawAirSpace(Surface, rc, _Proj); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } // In QUICKDRAW dont draw trail, thermals, glide terrain if (QUICKDRAW) { goto _skip_stuff; } DrawThermalEstimate(Surface, DrawRect, _Proj); if (OvertargetMode == OVT_THER) DrawThermalEstimateMultitarget(Surface, DrawRect, _Proj); // draw red cross on glide through terrain marker if (FinalGlideTerrain && DerivedDrawInfo.TerrainValid) { DrawGlideThroughTerrain(Surface, DrawRect, _Proj); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } _skip_stuff: if (IsMultimapAirspace() && AirspaceWarningMapLabels) { DrawAirspaceLabels(Surface, DrawRect, _Proj, Orig_Aircraft); if (DONTDRAWTHEMAP) { // 100319 goto QuickRedraw; } } if (IsMultimapWaypoints()) { DrawWaypointsNew(Surface, DrawRect); } if (TrailActive) { LKDrawLongTrail(Surface, Orig_Aircraft, DrawRect); // NEED REWRITING LKDrawTrail(Surface, DrawRect, _Proj); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } if ((Flags_DrawTask || TargetDialogOpen) && ValidTaskPoint(ActiveTaskPoint) && ValidTaskPoint(1)) { DrawTask(Surface, DrawRect, _Proj, Orig_Aircraft); } if (Flags_DrawFAI) { if (MapWindow::DerivedDrawInfo.Flying) { // FAI optimizer does not depend on tasks, being based on trace DrawFAIOptimizer(Surface, DrawRect, _Proj, Orig_Aircraft); } else { // not flying => show FAI sectors for the task if (ValidTaskPoint(ActiveTaskPoint) && ValidTaskPoint(1)) { DrawTaskSectors(Surface, DrawRect, _Proj); } } } // In QUICKDRAW do not paint other useless stuff if (QUICKDRAW) { if (extGPSCONNECT) DrawBearing(Surface, DrawRect, _Proj); goto _skip_2; } // --------------------------------------------------- DrawTeammate(Surface, rc, _Proj); if (extGPSCONNECT) { DrawBestCruiseTrack(Surface, Orig_Aircraft); DrawBearing(Surface, DrawRect, _Proj); } // draw wind vector at aircraft if (NOTANYPAN) { DrawWindAtAircraft2(Surface, Orig_Aircraft, DrawRect); } else if (mode.Is(Mode::MODE_TARGET_PAN)) { DrawWindAtAircraft2(Surface, Orig, rc); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } // Draw traffic and other specifix LK gauges LKDrawFLARMTraffic(Surface, DrawRect, _Proj, Orig_Aircraft); // --------------------------------------------------- _skip_2: if (NOTANYPAN) { if (IsMultimapOverlaysGauges()) { RenderOverlayGauges(Surface, rc); } if (TrackBar) { DrawHeading(Surface, Orig, DrawRect); if (ISGAAIRCRAFT) { DrawFuturePos(Surface, Orig, DrawRect); } } if (ISGAAIRCRAFT) { DrawHSIarc(Surface, Orig, DrawRect); } if (IsMultimapOverlaysText()) { DrawLook8000(Surface, rc); } DrawBottomBar(Surface, rc); } if (DONTDRAWTHEMAP) { goto QuickRedraw; } // Draw glider or paraglider if (extGPSCONNECT) { DrawAircraft(Surface, Orig_Aircraft); } #if USETOPOMARKS // marks on top... DrawMarks(hdc, rc); #endif if (!INPAN) { DrawMapScale(Surface, rc, zoom.BigZoom()); // unused BigZoom DrawCompass(Surface, rc, DisplayAngle); } #ifdef DRAWDEBUG DrawDebug(hdc, rc); #endif }
// @breif Patch the offsets to pass the signs. void CFW_SecondStage(void) { //Firm launch part //Check if firm.bin exists if (cfw_enablefirmlaunch) { if (FSFileOpen("/3ds/PastaCFW/firm.bin")) { FSFileClose(); if (Platform_CheckUnit() == PLATFORM_N3DS) { cfw_FWValue = 'd'; } else { cfw_FWValue = 'c'; } PrepareFirmLaunch(); firmlaunch = 1; } else { DrawDebug(0, 1, " ATTENTION!"); DrawDebug(0, 1, "Firm launch is enabled but firm.bin is missing"); DrawDebug(0, 1, "Download it with Companion App!"); DrawDebug(0, 1, "Press any key to continue..."); HidWaitForInput(); } } u8 patchO0[] = { 0x00, 0x20, 0x3B, 0xE0 }; u8 patchO1[] = { 0x00, 0x20, 0x08, 0xE0 }; u8 patchN0[] = { 0x01, 0x27, 0x1E, 0xF5 }; u8 patchN1[] = { 0xB4, 0xF9, 0xD0, 0xAB }; u8 patchN2[] = { 0x6D, 0x20, 0xCE, 0x77 }; u8 patchN3[] = { 0x5A, 0xC5, 0x73, 0xC1 }; u8 patchN4[] = { 0xE7, 0x08, 0x3F, 0x22 }; u8 patchN5[] = { 0x6F, 0x94, 0x72, 0x09 }; //Apply patches DrawDebug(0, 0, "Apply patch for type %c...", cfw_FWValue); switch (cfw_FWValue) { //Old-3DS case '1': // 4.x memcpy((u32*)0x080549C4, patchO0, 4); memcpy((u32*)0x0804239C, patchO1, 4); break; case '2': // 5.0 memcpy((u32*)0x08051650, patchO0, 4); memcpy((u32*)0x0803C838, patchO1, 4); break; case '3': // 5.1 memcpy((u32*)0x0805164C, patchO0, 4); memcpy((u32*)0x0803C838, patchO1, 4); break; case '4': // 6.0 memcpy((u32*)0x0805235C, patchO0, 4); memcpy((u32*)0x08057FE4, patchO1, 4); break; case '5': // 6.1 - 6.3 memcpy((u32*)0x08051B5C, patchO0, 4); memcpy((u32*)0x08057FE4, patchO1, 4); break; case '6': // 7.0-7.1 memcpy((u32*)0x080521C4, patchO0, 4); memcpy((u32*)0x08057E98, patchO1, 4); break; case '7': // 7.2 memcpy((u32*)0x080521C8, patchO0, 4); memcpy((u32*)0x08057E9C, patchO1, 4); break; case '8': // 8.x memcpy((u32*)0x080523C4, patchO0, 4); memcpy((u32*)0x08058098, patchO1, 4); break; case '9': // 9.x memcpy((u32*)0x0805235C, patchO0, 4); memcpy((u32*)0x08058100, patchO1, 4); break; //New-3DS case 'a': // 8.x memcpy((u32*)0x08053114, patchN0, 4); memcpy((u32*)0x080587E0, patchN1, 4); break; case 'b': // 9.x memcpy((u32*)0x08052FD8, patchN2, 4); memcpy((u32*)0x08058804, patchN3, 4); break; //FIRM_LAUNCH //Old 3DS case 'c': // 9.6 - 9.8 memcpy((u32*)0x0805252C, patchO0, 4); memcpy((u32*)0x08058094, patchO1, 4); break; //New 3DS case 'd': // 9.5 memcpy((u32*)0x0805219C, patchN4, 4); memcpy((u32*)0x08057F50, patchN5, 4); break; } DrawDebug(0, 1, "Apply patch for type %c... Done!", cfw_FWValue); DrawDebug(0, 1, ""); }
void CFW_Settings(void) { TOP_Current = 0; int settings_idx = 0; bool autobootgui = false; bool enable_firmlaunch = false; char settings[4]; if (FSFileOpen("/3ds/PastaCFW/system.txt")){ FSFileRead(settings, 4, 0); FSFileClose(); if (settings[1] == '2')autobootgui = true; if (settings[2] == '1' || settings[2] == '3')enable_firmlaunch = true; cfw_theme = settings[3]; } while (true) { //DRAW GUI sprintf(str, "/3ds/PastaCFW/UI/%c/options.bin", cfw_theme); DrawBottomSplash(str); TOP_Current = 0; drawInternalY = 0; DrawDebug(1, 1, ""); DrawDebug(1, 1, ""); DrawDebug(1, 1, ""); DrawDebug(1, 1, ""); int i; char* beg; for (i = 0; i < SETTINGS_ITEMS; i++) { if (i == settings_idx) beg = "->"; else beg = " "; if (i == 0)DrawSettingsDebug(1, "%s Always boot the GUI <%s>", beg, autobootgui ? "YES" : "NO "); else if (i == 1)DrawSettingsDebug(1, "%s Enable FirmLaunch <%s>", beg, enable_firmlaunch ? "YES" : "NO "); else if (i == 2)DrawSettingsDebug(1, "%s Change theme < %c >", beg, cfw_theme); DrawDebug(1, 1, ""); } //APP CONTROLS u32 pad_state = HidWaitForInput(); if (pad_state & BUTTON_DOWN) { if (settings_idx != SETTINGS_ITEMS - 1) settings_idx++; //MOVE DOWN else settings_idx = 0; //MOVE DOWN While at bottom -> go to top } else if (pad_state & BUTTON_UP) { if (settings_idx != 0) settings_idx--; //MOVE UP else settings_idx = SETTINGS_ITEMS - 1; //MOVE UP While at top -> go to bottom } else if (pad_state & BUTTON_LEFT || pad_state & BUTTON_RIGHT) { if (settings_idx == 0) autobootgui = !autobootgui; //autobootgui settings else if (settings_idx == 1) enable_firmlaunch = !enable_firmlaunch; //enable firmlaunch else if (settings_idx == 2) //theme selection { if (pad_state & BUTTON_LEFT && cfw_theme != '0') { cfw_theme--; sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme); //DRAW TOP SCREEN TO SEE THE NEW THEME DrawTopSplash(str); //TOP SCREEN } else if (pad_state & BUTTON_RIGHT && cfw_theme != '9') { sprintf(str, "/3ds/PastaCFW/UI/%c/options.bin", cfw_theme + 1); if (FSFileOpen(str)) { cfw_theme++; sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme);//DRAW TOP SCREEN TO SEE THE NEW THEME DrawTopSplash(str); } } } } else if (pad_state & BUTTON_A) { //SAVE SETTINGS FSFileOpen("/3ds/PastaCFW/system.txt"); char tobewritten[4]; tobewritten[0] = cfw_FWValue; tobewritten[1] = autobootgui ? '2' : '1'; tobewritten[2] = enable_firmlaunch ? '1' : '0'; tobewritten[3] = cfw_theme; cfw_enablefirmlaunch = enable_firmlaunch; FSFileWrite(tobewritten, 4, 0); FSFileClose(); break; } else if (pad_state & BUTTON_B) { cfw_theme = settings[3]; break; } //EXIT WITHOUT SAVING } }
void MapWindow::RenderMapWindowBg(HDC hdc, const RECT rc, const POINT &Orig, const POINT &Orig_Aircraft) { HFONT hfOld; // Calculations are taking time and slow down painting of map, beware #define MULTICALC_MINROBIN 5 // minimum split #define MULTICALC_MAXROBIN 20 // max split static short multicalc_slot=0;// -1 (which becomes immediately 0) will force full loading on startup, but this is not good // because currently we are not waiting for ProgramStarted=3 // and the first scan is made while still initializing other things // TODO assign numslots with a function, based also on available CPU time short numslots=1; #if NEWSMARTZOOM static double quickdrawscale=0.0; static double delta_drawscale=1.0; #endif // If we have a BigZoom request, we serve it immediately without calculating anything // TODO: stretch the old map bitmap to the new zoom, while fastzooming if (QUICKDRAW) { goto fastzoom; } if (NumberOfWayPoints>200) { numslots=NumberOfWayPoints/400; // keep numslots optimal if (numslots<MULTICALC_MINROBIN) numslots=MULTICALC_MINROBIN; // seconds for full scan, as this is executed at 1Hz if (numslots>MULTICALC_MAXROBIN) numslots=MULTICALC_MAXROBIN; // When waypointnumber has changed, we wont be using an exceeded multicalc_slot, which would crash the sw // In this case, we shall probably continue for the first round to calculate without going from the beginning // but this is not a problem, we are round-robin all the time here. if (++multicalc_slot>numslots) multicalc_slot=1; } else { multicalc_slot=0; // forcing full scan } // Here we calculate arrival altitude, GD etc for map waypoints. Splitting with multicalc will result in delayed // updating of visible landables, for example. The nearest pages do this separately, with their own sorting. // Basically we assume -like for nearest- that values will not change that much in the multicalc split time. // Target and tasks are recalculated in real time in any case. Nearest too. LKCalculateWaypointReachable(multicalc_slot, numslots); CalculateScreenPositionsAirspace(); CalculateScreenPositionsThermalSources(); CalculateScreenPositionsGroundline(); if (PGZoomTrigger) { if(!mode.Is(Mode::MODE_PANORAMA)) { mode.Special(Mode::MODE_SPECIAL_PANORAMA, true); LastZoomTrigger=GPS_INFO.Time; Message::Lock(); Message::AddMessage(1000, 3, gettext(TEXT("_@M872_"))); // LANDSCAPE ZOOM FOR 20s Message::Unlock(); #ifndef DISABLEAUDIO if (EnableSoundModes) LKSound(TEXT("LK_TONEUP.WAV")); #endif } else { // previously called, see if time has passed if ( GPS_INFO.Time > (LastZoomTrigger + 20.0)) { // time has passed, lets go back LastZoomTrigger=0; // just for safety mode.Special(Mode::MODE_SPECIAL_PANORAMA, false); PGZoomTrigger=false; Message::Lock(); Message::AddMessage(1500, 3, gettext(TEXT("_@M873_"))); // BACK TO NORMAL ZOOM Message::Unlock(); #ifndef DISABLEAUDIO if (EnableSoundModes) LKSound(TEXT("LK_TONEDOWN.WAV")); #endif } } } // let the calculations run, but dont draw anything but the look8000 when in MapSpaceMode != MSM_MAP if (DONTDRAWTHEMAP) { QuickRedraw: // 100318 speedup redraw DrawLook8000(hdc,rc); #ifdef CPUSTATS DrawCpuStats(hdc,rc); #endif #ifdef DRAWDEBUG DrawDebug(hdc,rc); #endif // no need to do SelectObject as at the bottom of function return; } // When no terrain is painted, set a background0 // Remember that in this case we have plenty of cpu time to spend for best result if (!EnableTerrain || !DerivedDrawInfo.TerrainValid || !RasterTerrain::isTerrainLoaded() ) { // display border and fill background.. SelectObject(hdc, hInvBackgroundBrush[BgMapColor]); SelectObject(hdc, GetStockObject(WHITE_PEN)); Rectangle(hdc,rc.left,rc.top,rc.right,rc.bottom); // We force LK painting black values on screen depending on the background color in use // TODO make it an array once settled // blackscreen would force everything to be painted white, instead LKTextBlack=BgMapColorTextBlack[BgMapColor]; if (BgMapColor>6 ) BlackScreen=true; else BlackScreen=false; } else { LKTextBlack=false; BlackScreen=false; } fastzoom: #if NEWSMARTZOOM // Copy the old background map with no overlays if (ONSMARTZOOM) { if (quickdrawscale>0) { delta_drawscale=zoom.DrawScale() / quickdrawscale; } // StartupStore(_T("... QuickDrawScale=%.2f new zoom=%.2f delta=%.2f\n"),quickdrawscale,zoom.DrawScale(),delta_drawscale); int dx=MapRect.right-MapRect.left; int dy=MapRect.bottom-MapRect.top; // notice: zoom in is always ok.. but zoom out starting from high zoom levels will make the picture // very small and unusable. We can consider to zoom out in fast zoom normally, in such cases? // // Notice 2: the delta is not yet working correctly // if (delta_drawscale>1.0) { // zoom in StretchBlt(hdcDrawWindow, 0,0, dx,dy, hdcQuickDrawWindow, (int)((dx/2) - (dx / delta_drawscale)/2), (int)((dy/2) - (dy / delta_drawscale)/2), (int)(dx / delta_drawscale), (int)(dy / delta_drawscale), SRCCOPY); } else { // zoom out StretchBlt(hdcDrawWindow, (int)((dx/2) - (dx * delta_drawscale)/2), (int)((dy/2) - (dy * delta_drawscale)/2), (int)(dx * delta_drawscale), (int)(dy * delta_drawscale), hdcQuickDrawWindow, 0,0, dx,dy, SRCCOPY); } } #endif SelectObject(hdc, GetStockObject(BLACK_BRUSH)); SelectObject(hdc, GetStockObject(BLACK_PEN)); hfOld = (HFONT)SelectObject(hdc, MapWindowFont); // ground first... if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } #if NEWSMARTZOOM if ( OFFSMARTZOOM ) { #endif if ((EnableTerrain && (DerivedDrawInfo.TerrainValid) && RasterTerrain::isTerrainLoaded()) ) { // sunelevation is never used, it is still a todo in Terrain double sunelevation = 40.0; double sunazimuth=GetAzimuth(); LockTerrainDataGraphics(); if (DONTDRAWTHEMAP) { // 100318 UnlockTerrainDataGraphics(); SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } DrawTerrain(hdc, rc, sunazimuth, sunelevation); // LOCKED 091105 if (DONTDRAWTHEMAP) { // 100318 UnlockTerrainDataGraphics(); SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } if (!QUICKDRAW) { // shaded terrain unreachable, aka glide amoeba #ifdef GTL2 if (((FinalGlideTerrain == 2) || (FinalGlideTerrain == 4)) && DerivedDrawInfo.TerrainValid) { #else if ((FinalGlideTerrain==2) && DerivedDrawInfo.TerrainValid) { #endif DrawTerrainAbove(hdc, rc); } } UnlockTerrainDataGraphics(); } #if NEWSMARTZOOM } #endif if (QUICKDRAW) { if ( !mode.AnyPan()) DrawLook8000(hdc,rc); SelectObject(hdcDrawWindow, hfOld); return; } if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } if (EnableTopology) { DrawTopology(hdc, rc); // LOCKED 091105 } #if 0 StartupStore(_T("... Experimental1=%.0f\n"),Experimental1); StartupStore(_T("... Experimental2=%.0f\n"),Experimental2); Experimental1=0.0; Experimental2=0.0; #endif // Topology labels are printed first, using OLD wps positions from previous run! // Reset for topology labels decluttering engine occurs also in another place here! nLabelBlocks = 0; #if TOPOFASTLABEL for (short nvi=0; nvi<SCREENVSLOTS; nvi++) nVLabelBlocks[nvi]=0; #endif if (ValidTaskPoint(ActiveWayPoint) && ValidTaskPoint(1)) { // 100503 DrawTaskAAT(hdc, rc); } if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } if (OnAirSpace > 0) // Default is true, always true at startup no regsave { if ( (GetAirSpaceFillType() == asp_fill_ablend_full) || (GetAirSpaceFillType() == asp_fill_ablend_borders) ) DrawTptAirSpace(hdc, rc); else DrawAirSpace(hdc, rc); } if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } if(TrailActive) { // NEED REWRITING LKDrawTrail(hdc, Orig_Aircraft, rc); } if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } DrawThermalEstimate(hdc, rc); if (OvertargetMode==OVT_THER) DrawThermalEstimateMultitarget(hdc, rc); // draw red cross on glide through terrain marker if (FinalGlideTerrain && DerivedDrawInfo.TerrainValid) { DrawGlideThroughTerrain(hdc, rc); } if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } if ((OnAirSpace > 0) && AirspaceWarningMapLabels) { DrawAirspaceLabels(hdc, rc, Orig_Aircraft); if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } } DrawWaypointsNew(hdc,rc); if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } if (ValidTaskPoint(ActiveWayPoint) && ValidTaskPoint(1)) { // 100503 DrawTask(hdc, rc, Orig_Aircraft); } DrawTeammate(hdc, rc); if (extGPSCONNECT) { DrawBestCruiseTrack(hdc, Orig_Aircraft); DrawBearing(hdc, rc); } // draw wind vector at aircraft if (!mode.AnyPan()) { DrawWindAtAircraft2(hdc, Orig_Aircraft, rc); } else if (mode.Is(Mode::MODE_TARGET_PAN)) { DrawWindAtAircraft2(hdc, Orig, rc); } #if NEWSMARTZOOM // Save the current rendered map before painting overlays if ( OFFSMARTZOOM ) { quickdrawscale=zoom.DrawScale(); BitBlt(hdcQuickDrawWindow, 0, 0, MapRect.right-MapRect.left, MapRect.bottom-MapRect.top, hdcDrawWindow, 0, 0, SRCCOPY); } #endif // VisualGlide drawn BEFORE lk8000 overlays if (!mode.AnyPan() && VisualGlide > 0) { DrawGlideCircle(hdc, Orig, rc); } if (DONTDRAWTHEMAP) { // 100319 SelectObject(hdcDrawWindow, hfOld); goto QuickRedraw; } // Draw traffic and other specifix LK gauges LKDrawFLARMTraffic(hdc, rc, Orig_Aircraft); if (!mode.AnyPan()) { // REMINDER TODO let it be configurable for not circling also, as before if ((mode.Is(Mode::MODE_CIRCLING)) ) if (ThermalBar) DrawThermalBand(hdcDrawWindow, rc); // 091122 DrawLook8000(hdc,rc); } if (LKVarioBar && !mode.AnyPan()) // 091214 do not draw Vario when in Pan mode LKDrawVario(hdc,rc); // 091111 // Draw glider or paraglider if (extGPSCONNECT) { DrawAircraft(hdc, Orig_Aircraft); } if (!mode.AnyPan()) { if (TrackBar) DrawHeading(hdc, Orig, rc); } #if USETOPOMARKS // marks on top... DrawMarks(hdc, rc); #endif if (ISGAAIRCRAFT) DrawHSI(hdc,Orig,rc); #ifdef CPUSTATS DrawCpuStats(hdc,rc); #endif #ifdef DRAWDEBUG DrawDebug(hdc,rc); #endif SelectObject(hdcDrawWindow, hfOld); }
//------------------------------------------------------------------------ void CGunTurret::UpdateOrientation(float deltaTime) { FUNCTION_PROFILER(GetISystem(), PROFILE_GAME); bool changed = false; bool searching = (m_targetId==0 && m_turretparams.searching); float speed = searching ? m_turretparams.search_speed : m_turretparams.turn_speed; assert(m_goalYaw >= 0.f && m_goalYaw <= gf_PI2); // update turret Matrix34 turretTM = GetEntity()->GetSlotLocalTM(eIGS_Aux0, false); Ang3 turretAngles(turretTM); if(turretAngles.z < 0.0f) turretAngles.z+=gf_PI2; if(cry_fabsf(m_goalYaw-turretAngles.z) > gf_PI) { if(m_goalYaw >= gf_PI) turretAngles.z += gf_PI2; else turretAngles.z -= gf_PI2; } if(m_turretparams.yaw_range < 360.f) { // reverse, to avoid forbidden range if(m_goalYaw > gf_PI && turretAngles.z < gf_PI) turretAngles.z += gf_PI2; else if(m_goalYaw < gf_PI && turretAngles.z > gf_PI) turretAngles.z -= gf_PI2; } if(cry_fabsf(turretAngles.z-m_goalYaw) > 0.001f) { Interp(turretAngles.z, m_goalYaw, speed, deltaTime, 0.25f*speed); if(m_turretSound == INVALID_SOUNDID && gEnv->IsClient()) m_turretSound = PlayAction(g_pItemStrings->turret); changed = true; } else if(m_turretSound != INVALID_SOUNDID) { StopSound(m_turretSound); m_turretSound = INVALID_SOUNDID; } if(changed) { turretTM.SetRotationXYZ(turretAngles,turretTM.GetTranslation()); GetEntity()->SetSlotLocalTM(eIGS_Aux0, turretTM); } // update weapon Matrix34 weaponTM = GetEntity()->GetSlotLocalTM(eIGS_ThirdPerson, false); Ang3 weaponAngles(weaponTM); weaponAngles.z = turretAngles.z; if(cry_fabsf(weaponAngles.x-m_goalPitch) > 0.001f) { Interp(weaponAngles.x, m_goalPitch, speed, deltaTime, 0.25f*speed); if(m_cannonSound == INVALID_SOUNDID && gEnv->IsClient()) m_cannonSound = PlayAction(g_pItemStrings->cannon); changed = true; } else if(m_cannonSound != INVALID_SOUNDID) { StopSound(m_cannonSound); m_cannonSound = INVALID_SOUNDID; } if(changed) { weaponTM.SetRotationXYZ(weaponAngles); Vec3 w_trans = turretTM.TransformPoint(m_radarHelperPos); //Vec3 w_trans = GetSlotHelperPos(eIGS_Aux0,m_radarHelper.c_str(),false); weaponTM.SetTranslation(w_trans); GetEntity()->SetSlotLocalTM(eIGS_ThirdPerson, weaponTM); if(GetEntity()->IsSlotValid(eIGS_Aux1)) { Vec3 b_trans = weaponTM.TransformPoint(m_barrelHelperPos); //Vec3 b_trans = GetSlotHelperPos(eIGS_ThirdPerson,m_barrelHelper.c_str(),false); weaponTM.SetTranslation(b_trans); GetEntity()->SetSlotLocalTM(eIGS_Aux1, weaponTM*m_barrelRotation); } if(gEnv->IsClient()) { for(TEffectInfoMap::const_iterator it=m_effects.begin(); it!=m_effects.end(); ++it) { Matrix34 tm(GetSlotHelperRotation(eIGS_ThirdPerson,it->second.helper.c_str(),true), GetSlotHelperPos(eIGS_ThirdPerson,it->second.helper.c_str(),true)); SetEffectWorldTM(it->first, tm); } } } UpdatePhysics(); if(g_pGameCVars->i_debug_turrets == eGTD_Basic) { DrawDebug(); //gEnv->pRenderer->DrawLabel(GetEntity()->GetWorldPos(), 1.4f, "%s yaw: %.2f, goalYaw: %.2f (%.2f), goalPitch: %.2f (%.2f/%.2f)", searching?"[search]":"", RAD2DEG(turretAngles.z), RAD2DEG(m_goalYaw), 0.5f*(m_turretparams.yaw_range), RAD2DEG(m_goalPitch), m_turretparams.min_pitch, m_turretparams.max_pitch); } }