void Startup(LPSTR lpCmdLine) { string4096 cmd; BOOL bModifyOptions = FALSE; strcpy_s(cmd,lpCmdLine); strlwr(cmd); if (strstr(cmd,"-?") || strstr(cmd,"-h")) { Help(); return; } if ((strstr(cmd,"-f")==0) && (strstr(cmd,"-g")==0) && (strstr(cmd,"-m")==0) && (strstr(cmd,"-s")==0) && (strstr(cmd,"-t")==0) && (strstr(cmd,"-c")==0) && (strstr(cmd,"-verify")==0) && (strstr(cmd,"-patch")==0)) { Help(); return; } if (strstr(cmd,"-o")) bModifyOptions = TRUE; // Give a LOG-thread a chance to startup InitCommonControls (); Sleep (150); thread_spawn (logThread, "log-update", 1024*1024,0); while (!logWindow) Sleep (150); u32 dwStartupTime = timeGetTime(); execute (cmd); // Show statistic char stats[256]; extern std::string make_time(u32 sec); extern HWND logWindow; u32 dwEndTime = timeGetTime(); sprintf (stats,"Time elapsed: %s",make_time((dwEndTime-dwStartupTime)/1000).c_str()); MessageBox (logWindow,stats,"Congratulation!",MB_OK|MB_ICONINFORMATION); bClose = TRUE; FlushLog (); Sleep (500); }
void run_client(const char* conf_str, const Config* cfg, bool create_db){ ClientPtr clp = nullptr; // SYSTEM-SPECIFIC std::string configdir = cfg->get<std::string>("configdir", "."); LOG("Creating client!\n"); FlushLog(); if (CreateWikiYesqlClient(conf_str, configdir.c_str(), &clp, create_db) == 0){ LOG("Created client; running program!\n"); FlushLog(); Workload workload = getWorkloadFromString(cfg->get<std::string>("workload", "")); RunWorkload(clp, workload, cfg); } delete clp; return; }
local void Csmodlog(const char *tc, const char *params, Player *p, const Target *target) { if (!strcasecmp(params, "flush")) FlushLog(); else if (!strcasecmp(params, "reopen")) ReopenLog(); }
void CBuild::u_Tesselate(tesscb_estimator* cb_E, tesscb_face* cb_F, tesscb_vertex* cb_V) { // main process FPU::m64r (); Status ("Tesselating..."); g_bUnregister = false; u32 counter_create = 0; u32 cnt_verts = lc_global_data()->g_vertices().size(); //u32 cnt_faces = g_faces.size(); for (u32 I=0; I<lc_global_data()->g_faces().size(); ++I) { Face* F = lc_global_data()->g_faces()[I]; if (0==F) continue; if( !check_and_destroy_splited( I ) ) continue; Progress (float(I)/float(lc_global_data()->g_faces().size())); int max_id = -1; if( !do_tesselate_face( *F, cb_E, max_id ) ) continue; xr_vector<Face*> adjacent_vec; Vertex *V1,*V2; CollectProblematicFaces( *F, max_id, adjacent_vec, &V1, &V2 ); ++counter_create; if (0==(counter_create%10000)) { for (u32 I=0; I<lc_global_data()->g_vertices().size(); ++I) if (lc_global_data()->g_vertices()[I]->m_adjacents.empty()) lc_global_data()->destroy_vertex (lc_global_data()->g_vertices()[I]); Status ("Working: %d verts created, %d(now) / %d(was) ...",counter_create,lc_global_data()->g_vertices().size(),cnt_verts); FlushLog (); } tessalate_faces( adjacent_vec, V1, V2, cb_F, cb_V ); } // Cleanup for (u32 I=0; I<lc_global_data()->g_faces().size(); ++I) if (0!=lc_global_data()->g_faces()[I] && lc_global_data()->g_faces()[I]->flags.bSplitted) lc_global_data()->destroy_face (lc_global_data()->g_faces()[I]); for (u32 I=0; I<lc_global_data()->g_vertices().size(); ++I) if (lc_global_data()->g_vertices()[I]->m_adjacents.empty()) lc_global_data()->destroy_vertex (lc_global_data()->g_vertices()[I]); lc_global_data()->g_faces().erase (std::remove(lc_global_data()->g_faces().begin(),lc_global_data()->g_faces().end(),(Face*)0),lc_global_data()->g_faces().end()); lc_global_data()->g_vertices().erase (std::remove(lc_global_data()->g_vertices().begin(),lc_global_data()->g_vertices().end(),(Vertex*)0),lc_global_data()->g_vertices().end()); g_bUnregister = true; }
void ClassAdLog::ForceLog() { // Force log changes to disk. This involves first flushing // the log from memory buffers, then fsyncing to disk. if (log_fp!=NULL) { // First flush FlushLog(); // Then sync if (condor_fsync(fileno(log_fp)) < 0) { EXCEPT("fsync of %s failed, errno = %d", logFilename(), errno); } } }
_Use_decl_annotations_ void writeAPIlog(Config* config, const char* fmt, ...) { va_list ap; memset(&ap, 0, sizeof(ap)); ReadWriteLock_AcquireRead(&config->lock); va_start(ap, fmt); Vfprintf(config->apilogfile, fmt, ap); va_end(ap); fprintf(config->apilogfile, "\r\n"); FlushLog(config->apilogfile); ReadWriteLock_ReleaseRead(&config->lock); }
void xrDebug::backend(const char* reason, const char* expression, const char *argument0, const char *argument1, const char* file, int line, const char *function, bool &ignore_always) { static xrCriticalSection CS; CS.Enter (); // Log string1024 tmp; xr_sprintf (tmp,"***STOP*** file '%s', line %d.\n***Reason***: %s\n %s",file,line,reason,expression); Msg (tmp); FlushLog (); if (handler) handler (); // Call the dialog dlgExpr = reason; xr_sprintf () dlgFile = file; xr_sprintf (dlgLine,"%d",line); INT_PTR res = -1; #ifdef XRCORE_STATIC MessageBox (NULL,tmp,"X-Ray error",MB_OK|MB_ICONERROR|MB_SYSTEMMODAL); #else res = DialogBox ( GetModuleHandle(MODULE_NAME), MAKEINTRESOURCE(IDD_STOP), NULL, DialogProc ); #endif switch (res) { case -1: case IDC_STOP: if (bException) TerminateProcess(GetCurrentProcess(),3); else RaiseException (0, 0, 0, NULL); break; case IDC_DEBUG: DEBUG_INVOKE; break; } CS.Leave (); }
__fastcall TfrmMain::TfrmMain(TComponent* Owner) : TForm(Owner) { // forms fraBottomBar = xr_new<TfraBottomBar> ((TComponent*)0); fraTopBar = xr_new<TfraTopBar> ((TComponent*)0); fraLeftBar = xr_new<TfraLeftBar> ((TComponent*)0); //- fraBottomBar->Parent = paBottomBar; fraTopBar->Parent = paTopBar; fraLeftBar->Parent = paLeftBar; if (paLeftBar->Tag > 0) paLeftBar->Parent = paTopBar; else paLeftBar->Parent = frmMain; Device.SetHandle (Handle,D3DWindow->Handle); EnableReceiveCommands (); if (!ExecCommand(COMMAND_INITIALIZE,(u32)D3DWindow,(u32)paRender)){ FlushLog (); TerminateProcess(GetCurrentProcess(),-1); } }
void xrSASH::LoopNative() { string_path in_file; FS.update_path(in_file, "$app_data_root$", m_strBenchCfgName); CInifile ini(in_file); IReader* R = FS.r_open(in_file); if (R) { FS.r_close(R); int test_count = ini.line_count("benchmark"); LPCSTR test_name, t; shared_str test_command; for (int i = 0; i < test_count; ++i) { ini.r_line("benchmark", i, &test_name, &t); //xr_strcpy(g_sBenchmarkName, test_name); test_command = ini.r_string_wb("benchmark", test_name); u32 cmdSize = test_command.size() + 1; Core.Params = (char*)xr_realloc(Core.Params, cmdSize); xr_strcpy(Core.Params, cmdSize, test_command.c_str()); xr_strlwr(Core.Params); RunBenchmark(test_name); // Output results ReportNative(test_name); } } else Msg("oa:: Native path can't find \"%s\" config file.", in_file); FlushLog(); }
int BladeNsLogWorker::BladeLeaveDs(LogCommand cmd, char * data, int length) { FlushLog(cmd, data, length); return 0; }
int BladeNsLogWorker::BladeDeleteFile(LogCommand cmd, char * data, int length) { FlushLog(cmd, data, length); return 0; }
int BladeNsLogWorker::BladeAbandonBlock(LogCommand cmd, char * data, int length) { FlushLog(cmd, data, length); return 0; }
int BladeNsLogWorker::BladeBlockReceived(LogCommand cmd, char * data, int length) { FlushLog(cmd, data, length); return 0; }
int MovingTrain::move(ElapsedTime currentTime,bool bNoLog) { PLACE_METHOD_TRACK_STRING(); switch(state) { case Birth: { InitTrain(); state = TrainFreeMoving; generateEvent(currentTime,false); } break; case TrainFreeMoving: { if (m_iPreState == Birth) { GetSchedule(currentTime); } else { GetSchedule(currentTime - m_TrainLogEntry.GetTurnAroundTime()); } int nCount = m_movePath.size(); double dPrevHeading = 0.0; for( int i=0; i<nCount; i++ ) { CViehcleMovePath movePath = m_movePath[i]; int nPathCount = movePath.GetCount(); float fPrevHeading; for( int z=0; z<nPathCount; z++ ) { CStateTimePoint timePt = movePath.GetItem( z ); TrainEventStruct event; ElapsedTime t; event.time = timePt.GetTime(); t.setPrecisely(event.time); if (currentTime < t) { currentTime = t; } event.x = (float)timePt.getX(); event.y = (float)timePt.getY(); event.z = (short)timePt.getZ(); if( z < nPathCount - 1 ) { CStateTimePoint nextTimePt = movePath.GetItem( z+1 ); double dNewHeading = ( nextTimePt - timePt ).getHeading(); event.heading = (float)dNewHeading; fPrevHeading = event.heading; } else { event.heading = fPrevHeading; } event.state = timePt.GetState(); m_TrainLogEntry.addEvent( event ); } } ElapsedTime delayTime; delayTime.setPrecisely(01l); generateEvent(currentTime - delayTime,false);//notify passenger train arrival m_iPreState = state; state = TrainArriveAtStation; } break; case TrainArriveAtStation: { if (m_nFlowIndex + 1 == (int)m_TrainFlow.size()) { m_nFlowIndex = 0; } m_nFlowIndex++; IntegratedStation* pSourceStation = GetSourceStation(m_nFlowIndex); pSourceStation->SetTrain(this); ElapsedTime delayTime; delayTime.setPrecisely(01l); generateEvent(currentTime + delayTime,false);//for correct time to leave state = TrainWaitForLeave; } break; case TrainWaitForLeave: { currentTime += m_TrainLogEntry.GetTurnAroundTime(); generateEvent(currentTime,false); m_iPreState = state; state = TrainLeaveStation; } break; case TrainLeaveStation: { if (m_TrainLogEntry.GetEndTime() < currentTime) { generateEvent(currentTime,false); state = Death; } else { generateEvent(currentTime,false); m_iPreState = state; state = TrainFreeMoving; } IntegratedStation* pSourceStation = GetSourceStation(m_nFlowIndex); pSourceStation->ClearStationTrain(this); ClearThisStationPerson(pSourceStation); } break; case Death: { FlushLog(); } break; default: break; } return TRUE; }
int flush_timer(void *dummy) { FlushLog(); return TRUE; }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- s32 retval; // Initialise the video system VIDEO_Init(); // This function initialises the attached controllers WPAD_Init(); // Obtain the preferred video mode from the system // This will correspond to the settings in the Wii menu rmode = VIDEO_GetPreferredMode(NULL); // Allocate memory for the display in the uncached region xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); // Initialise the console, required for printf console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); // Set up the video registers with the chosen mode VIDEO_Configure(rmode); // Tell the video hardware where our display memory is VIDEO_SetNextFramebuffer(xfb); // Make the display visible VIDEO_SetBlack(FALSE); // Flush the video register changes to the hardware VIDEO_Flush(); // Wait for Video setup to complete VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); if(usb_isgeckoalive(1))CON_EnableGecko(1, 1); log_buffer = (char*)malloc(0x4000); memset(log_buffer, 0, 0x4000); printf("Initializing WC24...\n"); retval = WC24_Init(); if(retval<0) { printf("WC24_Init returned %d\n", retval); return retval; } curtitleid = WC24_GetTitleID(); printf("\n\n"); printf("Getting NANDBOOTINFO argv...\n"); argv = WII_GetNANDBootInfoArgv(&argc, &launchcode); #ifdef WIILOADAPPDEBUG #ifdef WIILOADTEST_BOOTDISC argc = 1; launchcode = 2; #endif #ifdef WIILOADTEST_BOOTHB launchcode = 1; argc = 2; argv[1] = WIILOADTEST_BOOTHB; #endif #endif ResetWakeup_Timestamp(); #ifndef WIILOADAPPDEBUG retval = ProcessWC24(launchcode & BIT(25));//Don't do any WC24 stuff with HBC wiiload, only with the actual installed wc24boottitle. #endif launchcode &= ~(BIT(25)); ProcessArgs(argc, argv, 0); printf("Shutting down WC24...\n"); WC24_Shutdown(); FlushLog(); return 0; }
virtual void Execute(LPCSTR) { LogFile->clear_not_free (); FlushLog (); Msg ("* Log file has been cleaned successfully!"); }
void CHW::CreateDevice (HWND m_hWnd, bool move_window) { m_move_window = move_window; CreateD3D (); // General - select adapter and device //#ifdef DEDICATED_SERVER // BOOL bWindowed = TRUE; //#else // BOOL bWindowed = !psDeviceFlags.is(rsFullscreen); //#endif BOOL bWindowed = TRUE; #ifndef _EDITOR if (!g_dedicated_server) bWindowed = !psDeviceFlags.is(rsFullscreen); #else bWindowed = 1; #endif DevAdapter = D3DADAPTER_DEFAULT; DevT = Caps.bForceGPU_REF?D3DDEVTYPE_REF:D3DDEVTYPE_HAL; #ifndef MASTER_GOLD // Look for 'NVIDIA NVPerfHUD' adapter // If it is present, override default settings for (UINT Adapter=0;Adapter<pD3D->GetAdapterCount();Adapter++) { D3DADAPTER_IDENTIFIER9 Identifier; HRESULT Res=pD3D->GetAdapterIdentifier(Adapter,0,&Identifier); if (SUCCEEDED(Res) && (xr_strcmp(Identifier.Description,"NVIDIA PerfHUD")==0)) { DevAdapter =Adapter; DevT =D3DDEVTYPE_REF; break; } } #endif // MASTER_GOLD // Display the name of video board D3DADAPTER_IDENTIFIER9 adapterID; R_CHK (pD3D->GetAdapterIdentifier(DevAdapter,0,&adapterID)); Msg ("* GPU [vendor:%X]-[device:%X]: %s",adapterID.VendorId,adapterID.DeviceId,adapterID.Description); u16 drv_Product = HIWORD(adapterID.DriverVersion.HighPart); u16 drv_Version = LOWORD(adapterID.DriverVersion.HighPart); u16 drv_SubVersion = HIWORD(adapterID.DriverVersion.LowPart); u16 drv_Build = LOWORD(adapterID.DriverVersion.LowPart); Msg ("* GPU driver: %d.%d.%d.%d",u32(drv_Product),u32(drv_Version),u32(drv_SubVersion), u32(drv_Build)); Caps.id_vendor = adapterID.VendorId; Caps.id_device = adapterID.DeviceId; // Retreive windowed mode D3DDISPLAYMODE mWindowed; R_CHK(pD3D->GetAdapterDisplayMode(DevAdapter, &mWindowed)); // Select back-buffer & depth-stencil format D3DFORMAT& fTarget = Caps.fTarget; D3DFORMAT& fDepth = Caps.fDepth; if (bWindowed) { fTarget = mWindowed.Format; R_CHK(pD3D->CheckDeviceType (DevAdapter,DevT,fTarget,fTarget,TRUE)); fDepth = selectDepthStencil(fTarget); } else { switch (psCurrentBPP) { case 32: fTarget = D3DFMT_X8R8G8B8; if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE))) break; fTarget = D3DFMT_A8R8G8B8; if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE))) break; fTarget = D3DFMT_R8G8B8; if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE))) break; fTarget = D3DFMT_UNKNOWN; break; case 16: default: fTarget = D3DFMT_R5G6B5; if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE))) break; fTarget = D3DFMT_X1R5G5B5; if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE))) break; fTarget = D3DFMT_X4R4G4B4; if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE))) break; fTarget = D3DFMT_UNKNOWN; break; } fDepth = selectDepthStencil(fTarget); } if ((D3DFMT_UNKNOWN==fTarget) || (D3DFMT_UNKNOWN==fTarget)) { Msg ("Failed to initialize graphics hardware.\n" "Please try to restart the game.\n" "Can not find matching format for back buffer." ); FlushLog (); MessageBox (NULL,"Failed to initialize graphics hardware.\nPlease try to restart the game.","Error!",MB_OK|MB_ICONERROR); TerminateProcess (GetCurrentProcess(),0); } // Set up the presentation parameters D3DPRESENT_PARAMETERS& P = DevPP; ZeroMemory ( &P, sizeof(P) ); #ifndef _EDITOR selectResolution (P.BackBufferWidth, P.BackBufferHeight, bWindowed); #endif // Back buffer //. P.BackBufferWidth = dwWidth; //. P.BackBufferHeight = dwHeight; P.BackBufferFormat = fTarget; P.BackBufferCount = 1; // Multisample P.MultiSampleType = D3DMULTISAMPLE_NONE; P.MultiSampleQuality = 0; // Windoze P.SwapEffect = bWindowed?D3DSWAPEFFECT_COPY:D3DSWAPEFFECT_DISCARD; P.hDeviceWindow = m_hWnd; P.Windowed = bWindowed; // Depth/stencil P.EnableAutoDepthStencil= TRUE; P.AutoDepthStencilFormat= fDepth; P.Flags = 0; //. D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL; //AVO: functional vsync by avbaula #ifdef VSYNC_FIX P.PresentationInterval = selectPresentInterval(); // Vsync if(!bWindowed) P.FullScreen_RefreshRateInHz = selectRefresh(P.BackBufferWidth, P.BackBufferHeight,fTarget); #else //!VSYNC_FIX // Refresh rate P.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if( !bWindowed ) P.FullScreen_RefreshRateInHz = selectRefresh (P.BackBufferWidth, P.BackBufferHeight,fTarget); #endif //-VSYNC_FIX //-AVO else P.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; // Create the device u32 GPU = selectGPU(); HRESULT R = HW.pD3D->CreateDevice(DevAdapter, DevT, m_hWnd, GPU | D3DCREATE_MULTITHREADED, //. ? locks at present &P, &pDevice ); if (FAILED(R)) { R = HW.pD3D->CreateDevice( DevAdapter, DevT, m_hWnd, GPU | D3DCREATE_MULTITHREADED, //. ? locks at present &P, &pDevice ); } if (D3DERR_DEVICELOST==R) { // Fatal error! Cannot create rendering device AT STARTUP !!! Msg ("Failed to initialize graphics hardware.\n" "Please try to restart the game.\n" "CreateDevice returned 0x%08x(D3DERR_DEVICELOST)", R); FlushLog (); MessageBox (NULL,"Failed to initialize graphics hardware.\nPlease try to restart the game.","Error!",MB_OK|MB_ICONERROR); TerminateProcess (GetCurrentProcess(),0); }; R_CHK (R); _SHOW_REF ("* CREATE: DeviceREF:",HW.pDevice); switch (GPU) { case D3DCREATE_SOFTWARE_VERTEXPROCESSING: Log ("* Vertex Processor: SOFTWARE"); break; case D3DCREATE_MIXED_VERTEXPROCESSING: Log ("* Vertex Processor: MIXED"); break; case D3DCREATE_HARDWARE_VERTEXPROCESSING: Log ("* Vertex Processor: HARDWARE"); break; case D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE: Log ("* Vertex Processor: PURE HARDWARE"); break; } // Capture misc data #ifdef DEBUG R_CHK (pDevice->CreateStateBlock (D3DSBT_ALL,&dwDebugSB)); #endif R_CHK (pDevice->GetRenderTarget (0,&pBaseRT)); R_CHK (pDevice->GetDepthStencilSurface (&pBaseZB)); u32 memory = pDevice->GetAvailableTextureMem (); Msg ("* Texture memory: %d M", memory/(1024*1024)); Msg ("* DDI-level: %2.1f", float(D3DXGetDriverLevel(pDevice))/100.f); #ifndef _EDITOR updateWindowProps (m_hWnd); fill_vid_mode_list (this); #endif }
void xrDebug::do_exit (const std::string &message) { FlushLog (); MessageBox (NULL,message.c_str(),"Error",MB_OK|MB_ICONERROR|MB_SYSTEMMODAL); TerminateProcess (GetCurrentProcess(),1); }
void CloseLog(void) { FlushLog (); LogFile.clear (); }
void CloseLog(void) { FlushLog (); LogFile->clear (); xr_delete (LogFile); }
void logThread(void *dummy) { SetProcessPriorityBoost (GetCurrentProcess(),TRUE); logWindow = CreateDialog( HINSTANCE(GetModuleHandle(0)), MAKEINTRESOURCE(IDD_LOG), 0, logDlgProc ); if (!logWindow) { R_CHK (GetLastError()); }; SetWindowPos(logWindow,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); hwLog = GetDlgItem(logWindow, IDC_LOG); hwProgress = GetDlgItem(logWindow, IDC_PROGRESS); hwInfo = GetDlgItem(logWindow, IDC_INFO); hwStage = GetDlgItem(logWindow, IDC_STAGE); hwTime = GetDlgItem(logWindow, IDC_TIMING); hwPText = GetDlgItem(logWindow, IDC_P_TEXT); hwPhaseTime = GetDlgItem(logWindow, IDC_PHASE_TIME); SendMessage(hwProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); SendMessage(hwProgress, PBM_SETPOS, 0, 0); // Msg("\"LevelBuilder v4.1\" beta build\nCompilation date: %s\n",__DATE__); { char tmpbuf[128]; Msg("Startup time: %s",_strtime(tmpbuf)); } BOOL bHighPriority = FALSE; string256 u_name; unsigned long u_size = sizeof(u_name)-1; GetUserName (u_name,&u_size); _strlwr (u_name); if ((0==xr_strcmp(u_name,"oles"))||(0==xr_strcmp(u_name,"alexmx"))) bHighPriority = TRUE; // Main cycle u32 LogSize = 0; float PrSave = 0; while (TRUE) { SetPriorityClass (GetCurrentProcess(),IDLE_PRIORITY_CLASS); // bHighPriority?NORMAL_PRIORITY_CLASS:IDLE_PRIORITY_CLASS // transfer data while (!csLog.TryEnter()) { _process_messages ( ); Sleep (1); } if (progress>1.f) progress = 1.f; else if (progress<0) progress = 0; BOOL bWasChanges = FALSE; char tbuf [256]; csLog.Enter (); if (LogSize!=LogFile->size()) { bWasChanges = TRUE; for (; LogSize<LogFile->size(); LogSize++) { const char *S = *(*LogFile)[LogSize]; if (0==S) S = ""; SendMessage ( hwLog, LB_ADDSTRING, 0, (LPARAM) S); } SendMessage ( hwLog, LB_SETTOPINDEX, LogSize-1, 0); FlushLog ( ); } csLog.Leave (); if (_abs(PrSave-progress)>EPS_L) { bWasChanges = TRUE; PrSave = progress; SendMessage ( hwProgress, PBM_SETPOS, u32(progress*1000.f), 0); // timing if (progress>0.005f) { u32 dwCurrentTime = timeGetTime(); u32 dwTimeDiff = dwCurrentTime-phase_start_time; u32 secElapsed = dwTimeDiff/1000; u32 secRemain = u32(float(secElapsed)/progress)-secElapsed; sprintf(tbuf, "Elapsed: %s\n" "Remain: %s", make_time(secElapsed).c_str(), make_time(secRemain).c_str() ); SetWindowText ( hwTime, tbuf ); } else { SetWindowText ( hwTime, "" ); } // percentage text sprintf(tbuf,"%3.2f%%",progress*100.f); SetWindowText ( hwPText, tbuf ); } if (bStatusChange) { bWasChanges = TRUE; bStatusChange = FALSE; SetWindowText ( hwInfo, status); } if (bWasChanges) { UpdateWindow ( logWindow); bWasChanges = FALSE; } csLog.Leave (); _process_messages (); if (bClose) break; Sleep (200); } // Cleanup DestroyWindow(logWindow); }
void ProcessArgs(int argc, char **argv, int boothbdirect) { int i; s32 retval; u32 bootcode = launchcode & ~(0xff<<24);//Mask out the high 8-bits of launchcode, since that's used for options etc. char *path = (char*)0x900FFF00; void (*entry)() = (void*)0x80001800; u64 nandboot_titleid; YellHttp_Ctx *ctx; int use_wc24http = 0; u32 index; FILE *fdol; struct stat dolstats; if(!fatInitDefault())printf("FAT init failed.\n"); printf("Processing args...\n"); #ifndef WIILOADAPPDEBUG if(argc && !boothbdirect) { sscanf(argv[0], "%016llx", &nandboot_titleid); if(curtitleid!=nandboot_titleid) { printf("Current titleID and titleID from NANDBOOTINFO don't match: %016llx %s\n", curtitleid, argv[0]); argc = 0; } } #endif if(argc) { if(boothbdirect)launchcode = 1; if(launchcode & BIT(24))use_wc24http = 1; switch(bootcode) { case 1://Boot homebrew if(argc<2)break; if(!boothbdirect)printf("Booting homebrew from: %s\n", argv[1]); memcpy((void*)0x80001800, loader_bin, loader_bin_size); memset(path, 0, 256); if(!boothbdirect) { if(strncmp(argv[1], "http", 4)==0) { if(!use_wc24http) { printf("Using libyellhttp to download: %s\n", argv[1]); memset(localip, 0, 16); memset(netmask, 0, 16); memset(gateway, 0, 16); printf("Initializing network...\n"); retval = if_config (localip, netmask, gateway, true); if(retval<0) { printf("Network init failed: %d\n", retval); break; } ctx = YellHttp_InitCtx(); if(ctx==NULL) { printf("Failed to init/alloc http ctx.\n"); break; } printf("Downloading %s...\n", argv[1]); if(launchcode & BIT(26)) { WC24_MountWC24DlVFF(); chdir("wc24dl.vff:/"); } retval = YellHttp_ExecRequest(ctx, argv[1]); YellHttp_FreeCtx(ctx); if(retval<0) { memset(errstr, 0, 256); YellHttp_GetErrorStr(retval, errstr, 256); printf("retval = %d str: %s", retval, errstr); break; } for(i=strlen(argv[1])-1; i>0; i--) { if(argv[1][i]=='/')break; } i++; if(launchcode & BIT(26))strncpy(path, "wc24dl.vff:", 255); strncat(path, &argv[1][i], 255); } else { printf("Using WC24 to download: %s\n", argv[1]); printf("Creating record+entry...\n"); retval = WC24_CreateRecord(&myrec, &myent, 0, 0, 0x4842, WC24_TYPE_TITLEDATA, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, 0x3c, 0x5a0, 0, argv[1], VFFPATH "boot.dol"); if(retval<0) { printf("WC24_CreateRecord returned %d\n", retval); WC24_Shutdown(); break; } index = retval; printf("Downloading...\n"); retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)index, 0x0); if(retval<0) { printf("KD_Download returned %d\n", retval); WC24_DeleteRecord(index); WC24_Shutdown(); break; } printf("Deleting record+entry...\n"); WC24_DeleteRecord(index); printf("Mounting VFF...\n"); retval = WC24_MountWC24DlVFF(); if(retval<0) { printf("WC24_MountWC24DlVFF returned %d\n", retval); WC24_Shutdown(); break; } printf("Reading wc24dl.vff:/" VFFPATH "boot.dol...\n"); fdol = fopen("wc24dl.vff:/" VFFPATH "boot.dol", "r"); if(fdol==NULL) { printf("Failed to open wc24dl.vff:/" VFFPATH "boot.dol\n"); } else { stat("wc24dl.vff:/" VFFPATH "boot.dol", &dolstats); dol_size = dolstats.st_size; fread((void*)0x90100000, 1, dolstats.st_size, fdol); fclose(fdol); unlink("wc24dl.vff:/" VFFPATH "boot.dol"); DCFlushRange((void*)0x90100000, dolstats.st_size); } printf("Unmounting VFF...\n"); VFF_Unmount("wc24dl.vff"); memset(path, 0, 256); boothbdirect = 1; WII_SetNANDBootInfoLaunchcode(0); } } else { strncpy(path, argv[1], 255); } if(!use_wc24http) { if(strncmp(path, "dvd", 3)==0) { DI_Init(); if(!ISO9660_Mount()) { printf("Failed to mount DVD ISO9660.\n"); DI_Close(); break; } } stat(path, &dolstats); dol_size = dolstats.st_size; fdol = fopen(path, "r"); if(fdol==NULL) { printf("Dol doesn't exist: %s\n", argv[1]); break; } else { fread((void*)0x90100000, 1, dol_size, fdol); DCFlushRange((void*)0x90100000, dol_size); fclose(fdol); } memset(path, 0, 256); if(strncmp(path, "dvd", 3)==0) { ISO9660_Unmount(); DI_Close(); } if(launchcode & BIT(26)) { unlink(path); VFF_Unmount("wc24dl.vff"); } } } SetDolArgv((void*)0x90100000, dol_size, argc, argv); DCFlushRange((void*)0x80001800, loader_bin_size); DCFlushRange(path, 256); if(!boothbdirect)WII_SetNANDBootInfoLaunchcode(0); if(!boothbdirect) { printf("Booting: %s\n", path); } else { printf("Booting homebrew directly from RAM buffer.\n"); } WC24_Shutdown(); WPAD_Shutdown(); FlushLog(); //IOS_ReloadIOS(36); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); entry(); break; case 2://Boot game disc memcpy((void*)0x80001800, loader_bin, loader_bin_size); memset(path, 0, 256); memcpy((void*)0x90100000, tinyload_dol, tinyload_dol_size); DCFlushRange((void*)0x80001800, loader_bin_size); DCFlushRange(path, 256); DCFlushRange((void*)0x90100000, tinyload_dol_size); WII_SetNANDBootInfoLaunchcode(0); WC24_Shutdown(); WPAD_Shutdown(); printf("Booting game disc.\n"); FlushLog(); entry(); break; default: break; } } printf("Invalid launchcode or argc: %x %x\n", launchcode, argc); #ifdef DEBUG printf("Press A to contine.\n"); while(1) { WPAD_ScanPads(); if(WPAD_ButtonsDown(0) & WPAD_BUTTON_A)break; VIDEO_WaitVSync(); } #endif printf("Shutting down...\n"); printf("Shutting down WC24...\n"); if(launchcode & BIT(26))VFF_Unmount("wc24dl.vff"); WC24_Shutdown(); FlushLog(); WPAD_Shutdown(); WII_Shutdown(); }
virtual void Execute(LPCSTR /**args/**/) { FlushLog(); Msg ("* Log file has been saved successfully!"); }