/* BlankWindow - draw a blank window. * * hWnd handle of window to blank * fBorder TRUE => draw border, FALSE => erase border */ VOID PASCAL INTERNAL BlankWindow (HW hWnd, FLAG fBorder) { INT w = TWINWIDTH (hWnd); INT iBorder = hWnd->lLeft + hWnd->lRight; INT i; CHAR line[MAXLINELEN]; PSTR p = line; if (fBorder) { /* generate upper border */ DisplayTitle (hWnd); /* generate content line * some code removed and optimized N.B. if fBorder then we only * draw border, we do NOT blank content */ if ( iBorder ) { *p = (CHAR) C_V; for (i = 0; i < TWINHEIGHT (hWnd); i++) { WinOut (hWnd, 0, i+1, p, 1, DefNorm); WinOut (hWnd, w + iBorder - 1, i + 1, p, 1, DefNorm); } } DisplayFooter (hWnd); } else { memset (line, ' ', w + iBorder); for (i = 0; i < TWINHEIGHT (hWnd) + 2; i++) WinOut (hWnd, 0, i, line, w + iBorder, DefNorm); } }
/* SetWindowText - change the title of a window * * hWnd window whose title is to be changed * pTitle new title to be changed */ VOID PASCAL INTERNAL SetWindowText (HW hWnd, PSTR pTitle) { if (hWnd->pTitle != NULL) ZMfree (hWnd->pTitle); if (pTitle != NULL) hWnd->pTitle = ZMMakeStr (pTitle); else hWnd->pTitle = NULL; DisplayTitle (hWnd); }
int main(int argc, char* argv[]) { (void)argc; (void)argv; try { auto console = Core::CLog::GetLogger(Core::log_type::GENERAL); if(auto log = console.lock()) log->info( "Starting up server..." ); Core::Config& config = Core::Config::getInstance(); Core::CLog::SetLevel((spdlog::level::level_enum)config.map_server().log_level()); DisplayTitle(); CheckUser(); if(auto log = console.lock()) { log->set_level((spdlog::level::level_enum)config.map_server().log_level()); log->trace("Trace logs are enabled."); log->debug("Debug logs are enabled."); } Core::NetworkThreadPool::GetInstance(config.serverdata().maxthreads()); CMapServer clientServer; CMapServer iscServer(true); CMapISC* iscClient = new CMapISC(); iscClient->Init(config.map_server().charip(), config.map_server().chariscport()); iscClient->SetType(iscPacket::ServerType::CHAR); clientServer.Init(config.serverdata().ip(), config.map_server().clientport()); clientServer.Listen(); clientServer.GetISCList().push_front(iscClient); iscServer.Init(config.serverdata().ip(), config.map_server().iscport()); iscServer.Listen(); iscClient->Connect(); auto start = Core::Time::GetTickCount(); while (clientServer.IsActive()) { std::chrono::duration<double> diff = Core::Time::GetTickCount() - start; clientServer.update(diff.count()); start = Core::Time::GetTickCount(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); } if(auto log = console.lock()) log->info( "Server shutting down..." ); Core::NetworkThreadPool::DeleteInstance(); spdlog::drop_all(); } catch (const spdlog::spdlog_ex& ex) { std::cout << "Log failed: " << ex.what() << std::endl; } return 0; }
int main (int argc, char *argv[]) { int inc=0; start_time = time(NULL); GetArguments(argc, argv); /* Get the script filename */ PrintVersion(); /* Print info */ InitGFX(); /* Setup SDL */ DisplayTitle(); /* Show the irixbasic titles */ DisplayReady(); /* Display the ready text */ LoadScript(); SDL_Flip(screen); ubasic_init(program); /* Setup uBasic */ /* Start the program when the user is ready */ PrintTextLine("Click to Run."); SDL_Delay(200); do { GetInput(); /* Read the inputs */ }while (!GetMouseButton()); do { GetInput(); /* Read the inputs */ ubasic_run(); /* Process a line of code*/ }while (!ubasic_finished() && !done); PrintTextLine(""); PrintTextLine("Click or Press ESC to quit."); SDL_Flip(screen); while(!done && !GetMouseButton()){ GetInput(); } TTF_CloseFont( fntc64 ); return 0; }
VOID MainLoop(VOID) { WCHAR NameString[RES_BUFFER_SIZE]; DWORD NameIndex = 0; INT NameLength = 0; COORD xy; INT n = RES_DELAY_CHANGE; INT dir_y = 1; INT dir_x = 1; WORD wColor = 1; xy.X = ScreenBufferInfo.dwSize.X / 2; xy.Y = ScreenBufferInfo.dwSize.Y / 2; for ( ; 1; ++n ) { if (n == RES_DELAY_CHANGE) { n = 0; GetNextString(NameString, RES_BUFFER_SIZE, &NameIndex); NameLength = wcslen(NameString); wColor++; if ((wColor & 0x000F) == 0) wColor = 1; } if (xy.X == 0) { if (dir_x == -1) dir_x = 1; } else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1) { if (dir_x == 1) dir_x = -1; } xy.X += dir_x; if (xy.Y == 0) { if (dir_y == -1) dir_y = 1; } else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1) { if (dir_y == 1) dir_y = -1; } xy.Y += dir_y; #ifdef DISPLAY_COORD WriteCoord(xy); #endif /* def DISPLAY_COORD */ DisplayTitle(); WriteStringAt(NameString, xy, wColor); WaitForSingleObject(WaitableTimer, INFINITE); WriteStringAt(NameString, xy, 0); } }
/* Build the list of games in the open file f. * Returns 0 for success or error number. */ int GameListBuild (FILE *f) { ChessMove cm, lastStart; int gameNumber; ListGame *currentListGame = NULL; int error, scratch=100, plyNr=0, fromX, fromY, toX, toY; int offset; char lastComment[MSG_SIZ], buf[MSG_SIZ]; TimeMark t, t2; GetTimeMark(&t); GameListFree(&gameList); yynewfile(f); gameNumber = 0; movePtr = 0; lastStart = (ChessMove) 0; yyskipmoves = FALSE; do { yyboardindex = scratch; offset = yyoffset(); quickFlag = plyNr + 1; cm = (ChessMove) Myylex(); switch (cm) { case GNUChessGame: if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; if(1) { CopyBoard(boards[scratch], initialPosition); plyNr = 0; currentListGame->moves = PackGame(boards[scratch]); } if (currentListGame->gameInfo.event != NULL) { free(currentListGame->gameInfo.event); } currentListGame->gameInfo.event = StrSave(yy_text); lastStart = cm; break; case XBoardGame: lastStart = cm; break; case MoveNumberOne: switch (lastStart) { case GNUChessGame: break; /* ignore */ case PGNTag: lastStart = cm; break; /* Already started */ case (ChessMove) 0: case MoveNumberOne: case XBoardGame: if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; if(1) { CopyBoard(boards[scratch], initialPosition); plyNr = 0; currentListGame->moves = PackGame(boards[scratch]); } lastStart = cm; break; default: break; /* impossible */ } break; case PGNTag: lastStart = cm; if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; ParsePGNTag(yy_text, ¤tListGame->gameInfo); do { yyboardindex = 1; offset = yyoffset(); cm = (ChessMove) Myylex(); if (cm == PGNTag) { ParsePGNTag(yy_text, ¤tListGame->gameInfo); } } while (cm == PGNTag || cm == Comment); if(1) { int btm=0; if(currentListGame->gameInfo.fen) ParseFEN(boards[scratch], &btm, currentListGame->gameInfo.fen, FALSE); else CopyBoard(boards[scratch], initialPosition); plyNr = (btm != 0); currentListGame->moves = PackGame(boards[scratch]); } if(cm != NormalMove) break; case IllegalMove: if(appData.testLegality) break; case NormalMove: /* Allow the first game to start with an unnumbered move */ yyskipmoves = FALSE; if (lastStart == (ChessMove) 0) { if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; if(1) { CopyBoard(boards[scratch], initialPosition); plyNr = 0; currentListGame->moves = PackGame(boards[scratch]); } lastStart = MoveNumberOne; } case WhiteCapturesEnPassant: case BlackCapturesEnPassant: case WhitePromotion: case BlackPromotion: case WhiteNonPromotion: case BlackNonPromotion: case WhiteKingSideCastle: case WhiteQueenSideCastle: case BlackKingSideCastle: case BlackQueenSideCastle: case WhiteKingSideCastleWild: case WhiteQueenSideCastleWild: case BlackKingSideCastleWild: case BlackQueenSideCastleWild: case WhiteHSideCastleFR: case WhiteASideCastleFR: case BlackHSideCastleFR: case BlackASideCastleFR: fromX = currentMoveString[0] - AAA; fromY = currentMoveString[1] - ONE; toX = currentMoveString[2] - AAA; toY = currentMoveString[3] - ONE; plyNr++; ApplyMove(fromX, fromY, toX, toY, currentMoveString[4], boards[scratch]); if(currentListGame && currentListGame->moves) PackMove(fromX, fromY, toX, toY, boards[scratch][toY][toX]); break; case WhiteWins: // [HGM] rescom: save last comment as result details case BlackWins: case GameIsDrawn: case GameUnfinished: if(!currentListGame) break; if(currentListGame->gameInfo.result == GameUnfinished) currentListGame->gameInfo.result = cm; // correct result tag with actual result if (currentListGame->gameInfo.resultDetails != NULL) { free(currentListGame->gameInfo.resultDetails); } if(yy_text[0] == '{') { char *p; safeStrCpy(lastComment, yy_text+1, sizeof(lastComment)/sizeof(lastComment[0])); if((p = strchr(lastComment, '}'))) *p = 0; currentListGame->gameInfo.resultDetails = StrSave(lastComment); } break; default: break; } if(gameNumber % 1000 == 0) { snprintf(buf, MSG_SIZ, _("Reading game file (%d)"), gameNumber); DisplayTitle(buf); DoEvents(); } } while (cm != (ChessMove) 0); if(currentListGame) { if(!currentListGame->moves) DisplayError("Game cache overflowed\nPosition-searching might not work properly", 0); if (appData.debugMode) { for (currentListGame = (ListGame *) gameList.head; currentListGame->node.succ; currentListGame = (ListGame *) currentListGame->node.succ) { fprintf(debugFP, "Parsed game number %d, offset %ld:\n", currentListGame->number, currentListGame->offset); PrintPGNTags(debugFP, ¤tListGame->gameInfo); } } } if(appData.debugMode) { GetTimeMark(&t2);printf("GameListBuild %ld msec\n", SubtractTimeMarks(&t2,&t)); } quickFlag = 0; PackGame(boards[scratch]); // for appending end-of-game marker. DisplayTitle("WinBoard"); rewind(f); yyskipmoves = FALSE; return 0; }
void TaskStart ( void *data ) { PWINDOWS ptr = GetActiveWindow(); UBYTE i; char sCmd[MAX_X]; WORD key; WORD index, pos = 0x00; data = data; /* Prevent compiler warning */ OS_ENTER_CRITICAL(); PC_VectSet(0x08, OSTickISR); /* Install uC/OS-II's clock tick ISR */ PC_SetTickRate(OS_TICKS_PER_SEC); /* Reprogram tick rate */ OS_EXIT_CRITICAL(); PC_DispChar(0, 0, ' ', 0x00); PC_DispStr (8, 16, "Determining CPU's capacity ...", DISP_FGND_WHITE); CreateWindow (0, StartY, MAX_X, EndY, DISP_FGND_WHITE, DISP_BGND_BLUE, "[ Prompt Window ]"); CreateTaskWindows(); OSStatInit(); /* Initialize uC/OS-II's statistics */ for (i = 0; i < N_TASKS; i ++) { /* Create N_TASKS identical tasks */ TaskData[i] = '0' + i; /* Each task will display its own letter */ OSTaskCreate(Task, (void *)&TaskData[i], (void *)&TaskStk[i][TASK_STK_SIZE - 1], i + 1); } DisplayTitle(); ClearWindow(); memset(sCmd, 0x00, MAX_X); DisplayPrompt(); for (;;) { DisplayStatus(); // display status of tasks if (PC_GetKey(&key) == TRUE) { /* See if key has been pressed */ if (key == 0x1B) { /* Yes, see if it's the ESCAPE key */ PC_DOSReturn(); /* Return to DOS */ } else if (key == 0x08) // backspace { pos --; pos = pos <= 0x00 ? 0x00 : pos; sCmd[pos] = '\0'; PC_DispChar(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy, ' ', ptr->color); DisplayCursor(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy); } else if (key == 0x0d || key == 0x0a) // enter { if (pos) { index = ParseCommand(sCmd); HandleCommand(index); } memset(sCmd, 0x00, MAX_X); pos = 0x00; ptr->cy ++; if (ptr->cy == ptr->ey - 1) ClearWindow(); DisplayPrompt(); } else if ((key >= '0' && key <= '9') || (key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z')) { if (pos < MAX_X) { sCmd[pos] = (char)key; PC_DispChar(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy, key, ptr->color); DisplayCursor (ptr->cx + pos + strlen(sCmdPrompt) + 1, ptr->cy); } pos ++; } } OSTimeDlyHMSM(0, 0, 0, 200); /* Wait 200 ms */ } }