void TXT_GUIMainLoop(void) { main_loop_running = 1; while (main_loop_running) { TXT_DispatchEvents(); // After the last window is closed, exit the loop if (num_windows <= 0) { TXT_ExitMainLoop(); } TXT_DrawDesktop(); // TXT_DrawASCIITable(); if (periodic_callback == NULL) { TXT_Sleep(0); } else { TXT_Sleep(periodic_callback_period); periodic_callback(periodic_callback_data); } } }
void NET_WaitForLaunch(void) { if (!TXT_Init()) { fprintf(stderr, "Failed to initialize GUI\n"); exit(-1); } I_InitWindowIcon(); OpenWaitDialog(); had_warning = false; while (net_waiting_for_launch) { UpdateGUI(); CheckSHA1Sums(); CheckMasterStatus(); TXT_DispatchEvents(); TXT_DrawDesktop(); NET_CL_Run(); NET_SV_Run(); if (!net_client_connected) { I_Error("Lost connection to server"); } TXT_Sleep(100); } TXT_Shutdown(); }
void I_Endoom(void) { #ifndef GCONSOLE // I will return to this -- Hyper_Eye unsigned char *endoom_data; unsigned char *screendata; int y; int indent; // Hack to stop crash with disk icon in_endoom = true; endoom_data = (unsigned char *)W_CacheLumpName("ENDOOM", PU_STATIC); // Set up text mode screen TXT_Init(); I_SetWindowCaption(); I_SetWindowIcon(); // Write the data to the screen memory screendata = TXT_GetScreenData(); indent = (ENDOOM_W - TXT_SCREEN_W) / 2; for (y=0; y<TXT_SCREEN_H; ++y) { memcpy(screendata + (y * TXT_SCREEN_W * 2), endoom_data + (y * ENDOOM_W + indent) * 2, TXT_SCREEN_W * 2); } // Wait for a keypress while (true) { TXT_UpdateScreen(); if (TXT_GetChar() > 0) break; TXT_Sleep(0); } // Shut down text mode screen TXT_Shutdown(); in_endoom = false; #endif // Hyper_Eye }
void I_Endoom(void) { unsigned char *endoom_data; unsigned char *screendata; int y; int indent; endoom_data = W_CacheLumpName(DEH_String("ENDOOM"), PU_STATIC); // Set up text mode screen TXT_Init(); // Make sure the new window has the right title and icon I_SetWindowCaption(); I_SetWindowIcon(); // Write the data to the screen memory screendata = TXT_GetScreenData(); indent = (ENDOOM_W - TXT_SCREEN_W) / 2; for (y=0; y<TXT_SCREEN_H; ++y) { memcpy(screendata + (y * TXT_SCREEN_W * 2), endoom_data + (y * ENDOOM_W + indent) * 2, TXT_SCREEN_W * 2); } // Wait for a keypress while (true) { TXT_UpdateScreen(); if (TXT_GetChar() > 0) { break; } TXT_Sleep(0); } // Shut down text mode screen TXT_Shutdown(); }
// // I_EndDoom // // killough 2/22/98: Add support for ENDBOOM, which is PC-specific // killough 8/1/98: change back to ENDOOM // haleyjd 10/09/05: ENDOOM emulation thanks to fraggle and // Chocolate DOOM! // void I_EndDoom() { unsigned char *endoom_data; unsigned char *screendata; int start_ms; int lumpnum; // haleyjd: it's possible to have quit before we even initialized // GameModeInfo, so be sure it's valid before using it here. Also, // allow ENDOOM disable in configuration. if(!GameModeInfo || !showendoom) return; if((lumpnum = wGlobalDir.checkNumForName(GameModeInfo->endTextName)) < 0) return; endoom_data = (unsigned char *)wGlobalDir.cacheLumpNum(lumpnum, PU_STATIC); // Set up text mode screen if(!TXT_Init()) return; // Make sure the new window has the right title and icon SDL_WM_SetCaption("Thanks for using the Eternity Engine!", NULL); // Write the data to the screen memory screendata = TXT_GetScreenData(); memcpy(screendata, endoom_data, 4000); // Wait for 10 seconds, or until a keypress or mouse click // haleyjd: delay period specified in config (default = 350) start_ms = i_haltimer.GetTime(); while(i_haltimer.GetTime() < start_ms + endoomdelay) { TXT_UpdateScreen(); if(TXT_GetChar() > 0) break; TXT_Sleep(0); } // Shut down text mode screen TXT_Shutdown(); }
void I_Endoom(byte *endoom_data) { unsigned char *screendata; int y; int indent; // Set up text mode screen TXT_Init(); I_InitWindowTitle(); I_InitWindowIcon(); // Write the data to the screen memory screendata = TXT_GetScreenData(); indent = (ENDOOM_W - TXT_SCREEN_W) / 2; for (y=0; y<TXT_SCREEN_H; ++y) { memcpy(screendata + (y * TXT_SCREEN_W * 2), endoom_data + (y * ENDOOM_W + indent) * 2, TXT_SCREEN_W * 2); } // Wait for a keypress while (true) { TXT_UpdateScreen(); if (TXT_GetChar() > 0) { break; } TXT_Sleep(0); } // Shut down text mode screen TXT_Shutdown(); }
void TXT_GUIMainLoop(void) { main_loop_running = 1; while (main_loop_running) { TXT_DispatchEvents(); // After the last window is closed, exit the loop if (num_windows <= 0) { TXT_ExitMainLoop(); } TXT_DrawDesktop(); // TXT_DrawASCIITable(); TXT_Sleep(0); } }
static char *ExecReadOutput(char **argv) { char *result; int completed; int pid, status, result_len; int pipefd[2]; if (pipe(pipefd) != 0) { return NULL; } pid = fork(); if (pid == 0) { dup2(pipefd[1], fileno(stdout)); execv(argv[0], argv); exit(-1); } fcntl(pipefd[0], F_SETFL, O_NONBLOCK); // Read program output into 'result' string. // Wait until the program has completed and (if it was successful) // a full line has been read. result = NULL; result_len = 0; completed = 0; while (!completed || (status == 0 && (result == NULL || strchr(result, '\n') == NULL))) { char buf[64]; int bytes; if (!completed && waitpid(pid, &status, WNOHANG) != 0) { completed = 1; } bytes = read(pipefd[0], buf, sizeof(buf)); if (bytes < 0) { if (errno != EAGAIN && errno != EWOULDBLOCK) { status = -1; break; } } else { result = realloc(result, result_len + bytes + 1); memcpy(result + result_len, buf, bytes); result_len += bytes; result[result_len] = '\0'; } usleep(100 * 1000); TXT_Sleep(1); TXT_UpdateScreen(); } close(pipefd[0]); close(pipefd[1]); // Must have a success exit code. if (WEXITSTATUS(status) != 0) { free(result); result = NULL; } // Strip off newline from the end. if (result != NULL && result[result_len - 1] == '\n') { result[result_len - 1] = '\0'; } return result; }