void SplinterShowMonitorScreen() { byte b = 0; byte f = 14; unsigned y = 0; unsigned x = 0; // Draw the border SplinterDrawBorderedScreen(7, b); // Draw the title BlitterDrawText2(FontDataFontIndex, FontDataFontData, 15, x + 126, y + 11, 2, splinterTitle); BlitterDrawText2(FontDataFontIndex, FontDataFontData, 2, x + 125, y + 10, 2, splinterTitle); // Draw the message BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, x + 23, y + 38, 1, "Press ENTER if the rainbow colors"); BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, x + 23, y + 48, 1, "look correct. Otherwise press the "); BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, x + 23, y + 58, 1, "SPACEBAR until they look right."); // Draw the rainbow BlitterDrawGraphics(GrafxDataRainbowData, (byte)(x + 57), (byte)(y + 110)); // Show the screen CoCoMiscFadeIn(splinterRGBColorPalette, splinterCMPColorPalette, SPLINTER_FADE_DELAY, b); for(byte key = waitkey(0); key != 0; key = waitkey(0)) { // RGB or Yes we do not have an RGB monitor if ((key == 'r') || (key == 'R') || (key == 'y') || (key == 'Y')) { CoCoMiscSetRGBMode(1); break; } // Composite or No we do not have an RGB monitor if ((key == 'c') || (key == 'C') || (key == 'n') || (key == 'N')) { CoCoMiscSetRGBMode(0); break; } // Swap colors if (key == ' ') { CoCoMiscSetRGBMode(!CoCoMiscGetRGBMode()); CoCoMiscPaletteFade(splinterRGBColorPalette, splinterCMPColorPalette, 3, b); } // Enter pressed if (key == 13) break; } CoCoMiscFadeOut(splinterRGBColorPalette, splinterCMPColorPalette, SPLINTER_FADE_DELAY, b); }
char *minibuf_read_variable_name(char *msg) { char *ms; Completion *cp = completion_new(FALSE); le *lp; for (lp = mainVarList; lp != NULL; lp = lp->list_next) list_append(cp->completions, zstrdup(lp->data)); for (;;) { ms = minibuf_read_completion(msg, "", cp, NULL); if (ms == NULL) { free_completion(cp); cancel(); return NULL; } if (ms[0] == '\0') { free_completion(cp); minibuf_error("No variable name given"); return NULL; } else if (get_variable(ms) == NULL) { minibuf_error("Undefined variable name `%s'", ms); waitkey(WAITKEY_DEFAULT); } else { minibuf_clear(); break; } } free_completion(cp); return ms; }
static void pselecttst(void) { char c; int rc, opt=1; fprintf(stderr, "%s: START: testing std unix pselect functionality " "should echo keystrokes until 'q' key is pressed\n", __func__); tty_cbreak(STDIN_FILENO); ioctl(STDIN_FILENO, FIONBIO, &opt); while(1) { rc=waitkey(); if (rc==1) { c=fgetc(stdin); rc = write(STDOUT_FILENO, &c, 1); assert(rc==1); rc = write(STDOUT_FILENO, "\n", 1); assert(rc==1); if (c=='q') break; } else { fprintf(stderr,"THAT's ODD waitkey returned %d", rc); break; } } tty_reset(STDIN_FILENO); fprintf(stderr, "%s: END\n", __func__); }
/// <summary> /// Prints the specified error and exit. /// </summary> /// <param name="err">The error to output.</param> void error(String err) { std::cerr << "Fatal error occured: " + err << std::endl; std::cout << "Press any key to exit..." << std::endl; waitkey(); exit(-1); }
char *minibuf_read_variable_name(char *msg) { char *ms; historyp hp; hp = make_variable_history(); for (;;) { ms = minibuf_read_history(msg, "", hp); if (ms == NULL) { free_history(hp); cancel(); return NULL; } if (ms[0] == '\0') { free_history(hp); minibuf_error("No variable name given"); return NULL; } else if (get_variable(ms) == NULL) { minibuf_error("Undefined variable name"); waitkey(2 * 1000); } else { minibuf_clear(); break; } } free_history(hp); return ms; }
static int near edhorizontal (void) //************************************************************************* // // Zeileneditor, in dem alle horizontalen Cursorbewegungen und Eingaben // verarbeitet werden. Die Zeile wird komplett in einem Puffer bearbeitet // // Vertikale Aktionen werden an den Aufrufer zurueckgegeben // //************************************************************************* { int retwert = OK; int i = strlen(e->linbuf); unsigned a; memset(e->linbuf+i, ' ', LINLEN-i); // Rest der Zeile mit Blanks vorbesetzen e->linbuf[LINLEN] = 0; while (((a = (unsigned) waitkey()) & 255) != ESC) { retwert = a & 255; if ((bioskey(2) & 3) == 0) shiftgedrueckt = 0; if ((a & 255) == 0) { a >>= 8; retwert = (unsigned) a; if (horizontalswitch(a)) goto ende; } else {
int find_file(const char *filename) { Buffer *bp; char *s; for (bp = head_bp; bp != NULL; bp = bp->next) if (bp->filename != NULL && !strcmp(bp->filename, filename)) { switch_to_buffer(bp); return TRUE; } s = make_buffer_name(filename); if (strlen(s) < 1) { free(s); return FALSE; } if (!is_regular_file(filename)) { minibuf_error("%s is not a regular file", filename); waitkey(WAITKEY_DEFAULT); return FALSE; } bp = create_buffer(s); free(s); bp->filename = zstrdup(filename); switch_to_buffer(bp); read_from_disk(filename); thisflag |= FLAG_NEED_RESYNC; return TRUE; }
initFPGA::initFPGA(char *bitfile, char *serial) { //Create driver object dev = new okCFrontPanel; //Connect to device over serial if ( dev->OpenBySerial(std::string(serial)) != okCFrontPanel::NoError ) { printf("FATAL: Device could not be opened"); waitkey(); //closeFPGA(dev); exit(1); } else { //obtain device info and setup clocking PLL dev->GetDeviceInfo(&m_devInfo); dev->LoadDefaultPLLConfiguration(); //Device PLL configuration // Print some general information about the XEM. printf("Device detected: %s\n", m_devInfo.productName); printf("Device firmware version: %d.%d\n", m_devInfo.deviceMajorVersion, m_devInfo.deviceMinorVersion); printf("Device serial number: %s\n", m_devInfo.serialNumber); printf("Device device ID: %d \n\t=>Device PLL has now been configured...\n", m_devInfo.productID); // Download the bitfile file to target FPGA if ( dev->ConfigureFPGA(bitfile) != okCFrontPanel::NoError ) { printf("FPGA configuration failed.\n"); waitkey(); //closeFPGA(dev); exit(1); } // Check for FrontPanel support in the FPGA configuration. if (dev->IsFrontPanelEnabled()){ printf("\nFrontPanel support is enabled on Target Device.\n"); } else{ printf("FrontPanel support is not enabled on FPGA(Serial: %s) on port %s\n", m_devInfo.serialNumber, serial); waitkey(); exit(1); } //Device initialized! printf("\n\nInitialization complete. FPGA(Serial: %s) on port %s is ready for use.\n", m_devInfo.serialNumber, serial); } }
void showhelp(char far *heading,char far *text) { makewindow(9,5,70,21,heading); window(11,6,69,20); gotoxy(1,2); cprintf(text); window(1,1,80,25); waitkey(); closewindow(9,5,70,21); }
char getchar() { if (char_buffer >= 0) { int c = char_buffer; char_buffer = -1; return (char)c; } int c; for(c = waitkey(true); c == 0; c = inkey()); printf("%c", c); return (char)c; }
void SplinterShowTitleScreen() { BlitterClearScreen(0); // Draw the border byte b = 0, f = 14; SplinterDrawBorderedScreen(7, b); // Draw the title unsigned int x = 0, y = 0; BlitterDrawText2(FontDataFontIndex, FontDataFontData, 15, x + 120, y + 11, 2, "Splinter 1"); BlitterDrawText2(FontDataFontIndex, FontDataFontData, 2, x + 119, y + 10, 2, "Splinter 1"); y = 2; BlitterFillRectangle(60, y + 25, 200, 131, f); BlitterFillRectangle(61, y + 26, 198, 129, b); BlitterDrawGraphics(GrafxDataPaddleData, 33, (byte)y + 70); BlitterDrawGraphics(GrafxDataBallData, 53, (byte)y + 89); for(int ii=0; ii<128; ii += 8) { int yy = y + 27 + ii; BlitterFillRectangle(156, yy, 4, 7, 7); BlitterFillRectangle(156 + 1, yy + 1, 2, 5, 1); BlitterFillRectangle(171, yy, 4, 7, 7); BlitterFillRectangle(171 + 1, yy + 1, 2, 5, 3); BlitterFillRectangle(186, yy, 4, 7, 7); BlitterFillRectangle(186 + 1, yy + 1, 2, 5, 9); BlitterFillRectangle(201, yy, 4, 7, 7); BlitterFillRectangle(201 + 1, yy + 1, 2, 5, 5); BlitterFillRectangle(216, yy, 4, 7, 7); BlitterFillRectangle(216 + 1, yy + 1, 2, 5, 14); BlitterFillRectangle(231, yy, 4, 7, 7); BlitterFillRectangle(231 + 1, yy + 1, 2, 5, 14); BlitterFillRectangle(246, yy, 4, 7, 7); BlitterFillRectangle(246 + 1, yy + 1, 2, 5, 10); } BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, 74, 168, 1, "Press Any Key to Play"); CoCoMiscFadeIn(splinterRGBColorPalette, splinterCMPColorPalette, SPLINTER_FADE_DELAY, 0); waitkey(0); CoCoMiscFadeOut(splinterRGBColorPalette, splinterCMPColorPalette, SPLINTER_FADE_DELAY, b); }
int checkDLL() { char dll_date[32], dll_time[32]; if (FALSE == okFrontPanelDLL_LoadLib(NULL)) { printf("FATAL: okFrontPanel compiled library could not be loaded.\n"); waitkey(); return(-1); } else { okFrontPanelDLL_GetVersion(dll_date, dll_time); printf("FrontPanel DLL loaded. Built: %s %s\n", dll_date, dll_time); } return 0; }
int lookup_bool_variable(char *var) { char *p; if ((p = htable_fetch(var_table, var)) != NULL) return !strcmp(p, "true"); #if 0 minibuf_error("Warning: used uninitialized variable `@v%s@@'", var); waitkey(2 * 1000); #endif return FALSE; }
void SplinterShowGameOver() { // Location in character coordinates unsigned ww = 16, hh = 5; byte b = 0, f = 14; SplinterDrawDialogBox(ww, hh, f, b); // Locations in pixel coordinates unsigned xx = (40 - ww)/2, yy = (24 - hh)/2; unsigned x = xx * 8, y = yy * 8; // Draw the game over message BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, 120, y + 16, 1, "Game Over"); // Wait around a little so that the user does not make the game over disappear // too quickly CoCoMiscDelay(30000); waitkey(0); }
static void near ctrlk (void) //************************************************************************* // //************************************************************************* { int a; setzcurs(0, 255, e); wf(e->x+2, e->y, color.activ_frame, "^K"); a=waitkey() & 255; wf(e->x+2, e->y, color.activ_frame, "ŽŽ"); switch (a) { case 'b': e->blockbegin = e->readindex; break; case 'k': e->blockend = e->readindex; break; } }
void SplinterPauseGame() { // Location in character coordinates unsigned ww = 16, hh = 5; byte b = 0, f = 14; SplinterDrawDialogBox(ww, hh, f, b); // Locations in pixel coordinates unsigned xx = (40 - ww)/2, yy = (24 - hh)/2; unsigned x = xx * 8, y = yy * 8; // Draw the game paused message BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, 112, y + 16, 1, "Game Paused"); // Wait for the user to response waitkey(0); // Restore the screen SplinterEraseDialogBox(ww, hh, b); SplinterRefresh(); }
static void near ctrlq (void) //************************************************************************* // //************************************************************************* { int a; setzcurs(0, 255, e); wf(e->x+2, e->y, color.activ_frame, "^Q"); a = waitkey() & 255; wf(e->x+2, e->y, color.activ_frame, "ŽŽ"); switch (a) { case 'f': case 'a': suchen(); break; case 'n': zuzeile(); break; } }
static void paged_char(wchar_t c) { if (last_char_was_newline && number) { lineno++; printf("%6u ", lineno); } putchar(c); last_char_was_newline = c == '\n'; if (paging_enabled) { chars_remaining--; if (c == '\n' || chars_remaining == 0) { chars_remaining = console_cols; lines_remaining--; } if (lines_remaining == 0) { fflush(stdout); waitprompt(); waitkey(); newpage(); } } }
/// <summary> /// Hold screen for key press /// </summary> void hold_screen() { std::cout << "Press any key to continue..." << std::endl; waitkey(); }
void improveDDSep(domdec_t *dd) { bucket_t *b_bucket, *w_bucket; PORD_INT *xadj, *adjncy, *vwght, *vtype, *color, *cwght; PORD_INT *tmp_color, *deltaS, *deltaB, *deltaW; PORD_INT nvtx, weight, tmp_S, tmp_B, tmp_W; PORD_INT pos, bestglobalpos, badflips, b_domain, w_domain, domain, nxtdomain; PORD_INT fhead, ftail, u, v, i, istart, istop; FLOAT bestglobalvalue, b_value, w_value, value; /* ====================================================================== vtype[u]: (u domain) 1 => color of domain u has not been changed < 0 => points to next domain in flipping list (fhead points to first, ftail points to last domain in list) = 0 => domain is last domain in flipping list ====================================================================== */ nvtx = dd->G->nvtx; xadj = dd->G->xadj; adjncy = dd->G->adjncy; vwght = dd->G->vwght; vtype = dd->vtype; color = dd->color; cwght = dd->cwght; mymalloc(tmp_color, nvtx, PORD_INT); mymalloc(deltaS, nvtx, PORD_INT); mymalloc(deltaB, nvtx, PORD_INT); mymalloc(deltaW, nvtx, PORD_INT); OUTER_LOOP_START: /* ---------------------------------------------------------------------- copy data of actual bisection and initialize buckets and flipping list ---------------------------------------------------------------------- */ tmp_S = cwght[GRAY]; tmp_B = cwght[BLACK]; tmp_W = cwght[WHITE]; bestglobalpos = badflips = 0; bestglobalvalue = F(tmp_S, tmp_B, tmp_W); b_bucket = setupBucket(nvtx, nvtx, (nvtx >> 1)); w_bucket = setupBucket(nvtx, nvtx, (nvtx >> 1)); fhead = 0; ftail = -1; pos = 0; /* ---------------------------------------------------------- initialize tmp_color, deltaB, and deltaW for all multisecs ---------------------------------------------------------- */ for (u = 0; u < nvtx; u++) if (vtype[u] == 2) { deltaB[u] = deltaW[u] = 0; istart = xadj[u]; istop = xadj[u+1]; for (i = istart; i < istop; i++) { v = adjncy[i]; if (color[v] == BLACK) deltaB[u]++; else deltaW[u]++; } if ((deltaB[u] > 0) && (deltaW[u] > 0)) /* update multisec coloring */ tmp_color[u] = GRAY; else if (deltaB[u] > 0) tmp_color[u] = BLACK; else tmp_color[u] = WHITE; color[u] = tmp_color[u]; } /* ----------------------------------------------------------------- initialize tmp_color, deltaS,B,W for all domains and fill buckets ----------------------------------------------------------------- */ for (u = 0; u < nvtx; u++) if (vtype[u] == 1) { tmp_color[u] = color[u]; if (tmp_color[u] == BLACK) /* domain may be flipped to WHITE */ { deltaW[u] = vwght[u]; deltaB[u] = -deltaW[u]; deltaS[u] = 0; istart = xadj[u]; istop = xadj[u+1]; for (i = istart; i < istop; i++) { v = adjncy[i]; /* tmp_color[v] e {GRAY, BLACK} */ weight = vwght[v]; if (tmp_color[v] == BLACK) /* multisec v will move into S */ { deltaB[u] -= weight; deltaS[u] += weight; } else if (deltaB[v] == 1) /* multisec v will move into W */ { deltaW[u] += weight; deltaS[u] -= weight; deltaB[v] = -(u+1); } } insertBucket(b_bucket, deltaS[u], u); } if (tmp_color[u] == WHITE) /* domain may be flipped to BLACK */ { deltaB[u] = vwght[u]; deltaW[u] = -deltaB[u]; deltaS[u] = 0; istart = xadj[u]; istop = xadj[u+1]; for (i = istart; i < istop; i++) { v = adjncy[i]; /* tmp_color[v] e {GRAY, WHITE} */ weight = vwght[v]; if (tmp_color[v] == WHITE) /* multisec v will move into S */ { deltaW[u] -= weight; deltaS[u] += weight; } else if (deltaW[v] == 1) /* multisec v will move into B */ { deltaB[u] += weight; deltaS[u] -= weight; deltaW[v] = -(u+1); } } insertBucket(w_bucket, deltaS[u], u); } } #ifdef DEBUG printf("starting inner loop: b_bucket->nobj %d, w_bucket->nobj %d\n", b_bucket->nobj, w_bucket->nobj); waitkey(); #endif INNER_LOOP_START: /* ------------------------------------------- extract best domain from b_bucket, w_bucket ------------------------------------------- */ b_value = w_value = MAX_FLOAT; if ((b_domain = minBucket(b_bucket)) != -1) { b_value = F((tmp_S+deltaS[b_domain]), (tmp_B+deltaB[b_domain]), (tmp_W+deltaW[b_domain])); #ifdef DEBUG printf("best black domain: %d, deltaS %d, deltaB %d, deltaW %d, " "cost %7.2f\n", b_domain, deltaS[b_domain], deltaB[b_domain], deltaW[b_domain], b_value); #endif } if ((w_domain = minBucket(w_bucket)) != -1) { w_value = F((tmp_S+deltaS[w_domain]), (tmp_B+deltaB[w_domain]), (tmp_W+deltaW[w_domain])); #ifdef DEBUG printf("best white domain: %d, deltaS %d, deltaB %d, deltaW %d, " "cost %7.2f\n", w_domain, deltaS[w_domain], deltaB[w_domain], deltaW[w_domain], w_value); #endif } if ((b_domain == ERR) && (w_domain == ERR)) goto INNER_LOOP_END; if (b_value + EPS < w_value) { domain = b_domain; value = b_value; removeBucket(b_bucket, domain); } else { domain = w_domain; value = w_value; removeBucket(w_bucket, domain); } #ifdef DEBUG printf(" domain %d removed from bucket\n", domain); #endif /* ------------------------------------------------------------------- flip the color of domain and put it in list of log. flipped domains ------------------------------------------------------------------- */ if (ftail != -1) vtype[ftail] = -(domain+1); /* append domain */ else fhead = -(domain+1); /* list starts with domain */ vtype[domain] = 0; /* mark end of list */ ftail = domain; /* domain is last element in list */ if (tmp_color[domain] == BLACK) { tmp_color[domain] = WHITE; updateB2W(w_bucket,b_bucket,dd,domain,tmp_color,deltaW,deltaB,deltaS); } else if (tmp_color[domain] == WHITE) { tmp_color[domain] = BLACK; updateW2B(w_bucket,b_bucket,dd,domain,tmp_color,deltaW,deltaB,deltaS); } tmp_S += deltaS[domain]; tmp_B += deltaB[domain]; tmp_W += deltaW[domain]; pos++; if (value + EPS < bestglobalvalue) { bestglobalvalue = value; bestglobalpos = pos; badflips = 0; } else badflips++; if (badflips < MAX_BAD_FLIPS) goto INNER_LOOP_START; INNER_LOOP_END: /* -------------------------------------------- end of inner loop: now do the physical flips -------------------------------------------- */ pos = 0; nxtdomain = fhead; while (nxtdomain != 0) { domain = -nxtdomain - 1; if (pos < bestglobalpos) { if (color[domain] == BLACK) color[domain] = WHITE; else color[domain] = BLACK; cwght[GRAY] += deltaS[domain]; cwght[BLACK] += deltaB[domain]; cwght[WHITE] += deltaW[domain]; pos++; } nxtdomain = vtype[domain]; vtype[domain] = 1; } /* ---------------------------------------------- partition improved => re-start the whole stuff ---------------------------------------------- */ #ifdef DEBUG printf(" INNER_LOOP_END (#pyhs. flips %d): S %d, B %d, W %d (%7.2f)\n", bestglobalpos, cwght[GRAY], cwght[BLACK], cwght[WHITE], bestglobalvalue); waitkey(); #endif /* JY: moved next instruction after the two * freeBucket instructions because * this was the cause of a memory leak. * if (bestglobalpos > 0) goto OUTER_LOOP_START; */ freeBucket(b_bucket); freeBucket(w_bucket); if (bestglobalpos > 0) goto OUTER_LOOP_START; free(tmp_color); free(deltaS); free(deltaB); free(deltaW); }