int ui_ask_char(char const *msg, char *valid) { int x = strlen(msg) + 5; char c = 0; do { ui_statusline_clear(); if (c != 0) { ui_statusline_msg("Bad choice, press any key to try again"); getch(); ui_statusline_clear(); } ui_statusline_msg(msg); echo(); show_cursor(); c = mvwgetch(bottom, 0, x); noecho(); hide_cursor(); } while (!strchr(valid, c)); ui_statusline_clear(); return c; }
void draw_keymap(void) { // obtain the lock so no other thread can interrupt us pend(draw_lock); // figure out which x y to draw it at int x = keymap_loc[1]; int y = keymap_loc[0]; // draw the keymapping set_color(FG_BLACK); set_color_bold(BG_WHITE); goto_line(x, y+0); printf("[c] - Car in turn lane"); goto_line(x, y+1); printf("[w] - Press walk button"); goto_line(x, y+2); printf("[b] - Toggle broken"); goto_line(x, y+3); printf("[e] - Emergency for %d seconds", emergency_duration); goto_line(x, y+4); printf(" [-/+] - Inc/Dec"); goto_line(x, y+5); printf("[m] - Toggle manual"); goto_line(x, y+6); printf(" [j/k] - Next/Prev light"); goto_line(x, y+7); printf(" [1/2/3] - Red/Yellow/Green"); goto_line(x, y+8); printf("[r] - Redraw"); reset_color(); hide_cursor(); // we're done, release the lock post(draw_lock); }
void showtimer(void) { int timeleft = lastgrab + grabtimeout - time(0); int lenx; Pixel text_color = White; // was brightwhite Pixel bar_color; Rectangle thisbar_r = bar_r; char buf[50]; if (grabtimeout == 0) return; thisbar_r = bar_r; thisbar_r.max.x = bar_r.min.x + ((bar_r.max.x - bar_r.min.x)*timeleft/grabtimeout); hide_cursor(); clear_timer(); if (timeleft > WARNTIME) bar_color = Green; else if (timeleft > ALARMTIME) { bar_color = Yellow; } else bar_color = Red; snprintf(buf, sizeof(buf), " Seconds left: %d", timeleft); fill_rect(thisbar_r, bar_color); write_string(timer_r.min, text_color, buf); show_cursor(); }
void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int citem ) { int curtime; nitems = nitems; items=items; citem = citem; //draw copyright message if ( Menu_draw_copyright ) { Menu_draw_copyright = 0; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(6,6,6),-1); gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,TXT_COPYRIGHT); } // Don't allow them to hit ESC in the main menu. if (*last_key==KEY_ESC) *last_key = 0; if ( do_auto_demo ) { curtime = timer_get_fixed_seconds(); //if ( ((keyd_time_when_last_pressed+i2f(20)) < curtime) && ((last_joy_time+i2f(20)) < curtime) && (!speedtest_on) ) { if ( ((keyd_time_when_last_pressed+i2f(45)) < curtime) && (!speedtest_on) ) { hide_cursor(); keyd_time_when_last_pressed = curtime; // Reset timer so that disk won't thrash if no demos. newdemo_start_playback(NULL); // Randomly pick a file if (Newdemo_state == ND_STATE_PLAYBACK) { Function_mode = FMODE_GAME; *last_key = -2; } } } }
static bool raspberrypi_set_mouse_cursor(ALLEGRO_DISPLAY *display, ALLEGRO_MOUSE_CURSOR *cursor) { ALLEGRO_DISPLAY_RASPBERRYPI *d = (void *)display; ALLEGRO_MOUSE_CURSOR_RASPBERRYPI *pi_cursor = (void *)cursor; int w = al_get_bitmap_width(pi_cursor->bitmap); int h = al_get_bitmap_height(pi_cursor->bitmap); int pitch = w * sizeof(uint32_t); uint32_t *data = al_malloc(pitch * h); ALLEGRO_LOCKED_REGION *lr = al_lock_bitmap(pi_cursor->bitmap, ALLEGRO_PIXEL_FORMAT_ARGB_8888, ALLEGRO_LOCK_READONLY); int y; for (y = 0; y < h; y++) { uint8_t *p = (uint8_t *)lr->data + lr->pitch * y; uint8_t *p2 = (uint8_t *)data + pitch * y; memcpy(p2, p, pitch); } al_unlock_bitmap(pi_cursor->bitmap); delete_cursor_data(d); set_cursor_data(d, data, w, h); al_free(data); if (cursor_added) { hide_cursor(d); show_cursor(d); } return true; }
bool save_game( void) { pause_game(); show_cursor(); /* Translate the name, and display the dialog */ FileSpecifier SaveFile; get_current_saved_game_name(SaveFile); char GameName[256]; SaveFile.GetName(GameName); char Prompt[256]; // Must allow the sound to play in the background bool success = SaveFile.WriteDialogAsync( _typecode_savegame, getcstr(Prompt, strPROMPTS, _save_game_prompt), GameName); if (success) success = save_game_file(SaveFile); hide_cursor(); resume_game(); return success; }
uint16_t best_move(int side) { // returns best move, otherwise 0 if no legal moves exist hide_cursor(); uint16_t best_move = 0; int best_score = 2 * side - 1; // calculate this so we don't have to branch =D // if side is 0 (white), we use a factor of (1) // if side is 1 (black), we negate (-1) int branch = -2 * side + 1; // 2 * side - 1 = score uint16_t move = 1; for(int i = 0; i < 16; i++){ //printf("considering move : 0x%X\n", move); if(is_legal(move)){ int score = minimax[side](move, 0); //printf("finite recursion\n"); if(score * branch > best_score * branch){ best_score = score; best_move = move; } } move <<= 1; } show_cursor(); return best_move; }
static bool raspberrypi_show_mouse_cursor(ALLEGRO_DISPLAY *display) { ALLEGRO_DISPLAY_RASPBERRYPI *d = (void *)display; hide_cursor(d); show_cursor(d); return true; }
static void text_loglevel_change() { /* Only reset the display if we're switching between nice display * and displaying debugging output */ if (console_loglevel >= SUSPEND_ERROR) { if (lastloglevel < SUSPEND_ERROR) clear_display(); show_cursor(); if (lastloglevel > -1) printf("\nSwitched to console loglevel %d.\n", console_loglevel); if (lastloglevel > -1 && lastloglevel < SUSPEND_ERROR) { printf("\n** %s\n", lastheader); } } else if (lastloglevel >= SUSPEND_ERROR || lastloglevel == -1) { clear_display(); hide_cursor(); /* Get the nice display or last action [re]drawn */ text_prepare_status(1, 0, SUSPEND_UI_MSG, NULL); } lastloglevel = console_loglevel; }
int main(void) { print("kernel : gdt loaded\n"); init_idt(); print("kernel : idt loaded\n"); init_pic(); print("kernel : pic configured\n"); hide_cursor(); /* Initialisation du TSS */ asm(" movw $0x38, %ax \n \ ltr %ax"); print("kernel : tr loaded\n"); /* Initialisation de la memoire */ init_mm(); print("kernel : paging enable\n"); sti; print("kernel : interrupts enable\n"); //init_serial(); //print("kernel : serial port enable\n"); // BochsConsolePrint("Bonjour\n"); while (1); }
void draw_frame(void) { // obtain the lock so no other thread can interrupt us pend(draw_lock); clear_screen(); goto_line(0,0); set_color_bold(FG_BLACK); set_color_bold(BG_WHITE); int x, y; for (y = 0; y < FRAME_HEIGHT; y++) { for (x = 0; x < FRAME_WIDTH; x++) { switch (frame[y][x]) { case '-': printf("\u2500"); break; case '|': printf("\u2502"); break; case ' ': printf(" "); break; default: printf("%s", pipes[frame[y][x]-'0']); } } printf("\n"); } reset_color(); hide_cursor(); // we're done, release the lock post(draw_lock); }
void draw_car(char yes) { // obtain the lock so no other thread can interrupt us pend(draw_lock); // reset the colors reset_color(); // if we are drawing a car make it cyan if (yes) set_color_bold(BG_CYAN); // draw car 0 goto_line(street_loc[1]+car_loc[0][1]-1, street_loc[1]+car_loc[0][0]-1); printf(" "); // draw car 1 goto_line(street_loc[1]+car_loc[1][1]-1, street_loc[1]+car_loc[1][0]-1); printf(" "); reset_color(); hide_cursor(); // we're done, release the lock post(draw_lock); }
void ui_statusline_ask_char(char *msg, char *c, char* valid) { int x = strlen(msg) + 5; char input[STRING_SHORT]; *c = 0; do { ui_statusline_clear(); if(*c != 0){ ui_statusline_msg("Bad choice, press any key to try again"); getch(); ui_statusline_clear(); } ui_statusline_msg(msg); echo(); show_cursor(); *c = mvwgetch(bottom, 1, x); noecho(); hide_cursor(); } while ( !strchr(valid, *c) ); ui_statusline_clear(); }
char * ui_statusline_ask_str_with_autogen(char *msg, char *input, int len, char *(*autogen)(char *), int ch) { int i = 0; int c; char *text[2], *s; int x; if(input == NULL){ input = malloc(len); } text[0] = malloc(STRING_MEDIUM); text[1] = malloc(STRING_SHORT); strncpy(text[1], msg, STRING_SHORT); if(s = strrchr(text[1], ':')){ *s = 0; } snprintf(text[0], STRING_MEDIUM, "%s(%c for autogen):\t", text[1],ch); x = strlen(text[0]) + 5; ui_statusline_clear(); ui_statusline_msg(text[0]); show_cursor(); noecho(); wmove(bottom, 1, x); while(i < len){ c = wgetch(bottom); if(c == 0x7f){ if(i){ i--; mvwaddch(bottom, 1, x+i, ' '); wmove(bottom, 1, x+i); } } else if(c == 0xd){ input[i] = 0; break; } else if(c == ch){ input = autogen(input); break; } else { input[i] = c; mvwaddch(bottom, 1, x + i, c); i++; } } hide_cursor(); ui_statusline_clear(); free(text[0]); free(text[1]); return input; }
static void pointer_handle_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy) { GLWin.pointer.serial = serial; hide_cursor(); }
void draw_reset(void) { clear_screen(); draw_frame(); draw_keymap(); draw_street(); draw_walk(RED); draw_lights(); hide_cursor(); }
static gboolean key_press_cb (ClutterActor *actor, ClutterEvent *event, gpointer data) { hide_cursor (); if (!(event->type == CLUTTER_KEY_PRESS)) return FALSE; return gnibbles_keypress_worms (event->key.keyval); }
static void autohide_cursor(glw_x11_t *gx11) { if(gx11->cursor_hidden) return; if(gx11->autohide_counter == 0) hide_cursor(gx11); else gx11->autohide_counter--; }
static void autohide_cursor(glw_x11_t *gx11) { if(gx11->cursor_hidden) return; if(gx11->autohide_counter == 0) hide_cursor(gx11); else if(gx11->gr.gr_pointer_grab == NULL) gx11->autohide_counter--; }
void display(void) { int i, j; for (i = 0; i < num_rows; i++) for (j = 0; j < num_columns; j++) { if (field_of_play[i][j]->read()) write_xyc(2*j, i, 'X'); else write_xyc(2*j, i, '.'); } hide_cursor(); }
void init(void) { exceptions_init(); hide_cursor(); vga_setcolor(0x07); pic_init(); idt_write_table(); kb_init(); //Init keyboard driver floppy_init(); lex_init(); printf("\nSystem booted.\n\n"); }
void kmain(struct multiboot* b, uint32_t magic) { hide_cursor(); cls(); setup_gdt(); setup_idt(); if(b->mods_count == 1) { uint32_t mods_start_addr=*(uint32_t*)(b->mods_addr); uint32_t mods_end_addr=*(uint32_t*)(b->mods_addr + 4); if(((uint32_t)&__kernel_end - KERNEL_VMA) < mods_end_addr) kernel_end_addr=(mods_end_addr & 0xFFFFF000) + 0x1000; } setup_bitmap(); setup_vmm(); setup_pic(); setup_tasking(); setup_process_tree(); set_timer_freq(100); pci_init(); setup_network(); b=(struct multiboot*)((uint8_t*)b+KERNEL_VMA); uint32_t mods_addr=*(uint32_t*)(b->mods_addr + KERNEL_VMA) + KERNEL_VMA; root_fs=ext2_fs_init((uint8_t*)mods_addr); struct inode *devfs=devfs_init(); struct inode *devfs_root=vfs_search((struct inode*)root_fs, "/dev"); if(devfs_root) { vfs_mount(devfs, devfs_root); register_tty_driver(); register_kbd_driver(); register_rtl8139_driver(); } else kprintf("Could not mount /dev, no such directory\n"); kprintf("\n%@Welcome to tapiOS!%@\n\n", 0x05, 0x07, b->mods_count, 0x03); struct inode *node=vfs_search((struct inode*)root_fs, "/bin/init"); if(node) { struct file *init=vfs_open(node, NULL, O_RDONLY); uint8_t *init_mem=kmalloc(node->size); int read=vfs_read(init, init_mem, node->size); vaddr_t entrypoint=init_elf_get_entry_point(init_mem); setup_initial_process(entrypoint); } else kprintf("Init not found\n"); __asm__ volatile("hltloop: hlt; jmp hltloop"); PANIC(); }
int main(int argc, char **argv){ unsigned type = PLR_X_CPU; int key_pressed = 0; awake_the_weaver(); // Initializing Weaver API hide_cursor(); copyleft(); intro(); surface *title = new_image("title.png"); for(;;){ int esc_pressed = 0; int x = (window_width - title -> width) / 2; int y = (window_height - title -> height) / 2; fill_screen(BLACK); draw_surface(title, window, x, y); draw_gametype(type % 4, x + 120, y + 60); key_pressed = 0; for(;;){ get_input(); if(keyboard[ESC]){ esc_pressed = 1; break; } if(keyboard[ENTER]){ fill_screen(BLACK); flush(); game(type % 4); break; } else if(keyboard[LEFT]){ if(!key_pressed){ type --; draw_gametype(type % 4, x + 120, y + 60); } } else if(keyboard[RIGHT]){ if(!key_pressed){ type ++; draw_gametype(type % 4, x + 120, y + 60); } } key_pressed = keyboard[ANY]; weaver_rest(10000000); } if(esc_pressed) break; } destroy_surface(title); may_the_weaver_sleep(); return 0; }
void blue_screen_putchar(char c) { if (sScreen.ignore_output && (in_command_invocation() || sScreen.boot_debug_output)) return; sScreen.ignore_output = false; hide_cursor(); parse_character(c); update_cursor(sScreen.x, sScreen.y); }
void Textgrafs::print(){ cursorpos(0,0); hide_cursor(); std::string s; for(int y = 0; y < grid.size(); ++y){ for(int x = 0; x < grid[y].size();++x){ s+= grid[y][x]; } s+= "\033[0m\n"; } s.pop_back(); std::cout << s; show_cursor(); }
static void winch_handler (int signum) { clock_freeze (); delwin (moon); delwin (status); delwin (message); sleep (1); endwin (); refresh (); allocate_windows (); hide_cursor (); mode_redraw (); clock_thaw (); }
char * ui_statusline_ask_passwd(char *msg, char *input, int len, int cancel) { int i = 0; int c; int x = strlen(msg) + 5; if(!input){ input = malloc(len); } ui_statusline_clear(); ui_statusline_msg(msg); show_cursor(); noecho(); wmove(bottom, 1, x); while(i < len){ c = wgetch(bottom); if(c == 0x7f){ /* 0x7f = delete */ if(i){ i--; mvwaddch(bottom, 1, x+i, ' '); wmove(bottom, 1, x+i); } } else if(c == 0xd){ /* 0xd == enter/return */ input[i] = 0; break; } else if(c == cancel){ free(input); input = NULL; return input; } else { input[i] = c; mvwaddch(bottom, 1, x + i, '*'); i++; } } hide_cursor(); ui_statusline_clear(); return input; }
void blue_screen_puts(const char *text) { if (sScreen.ignore_output && (in_command_invocation() || sScreen.boot_debug_output)) return; sScreen.ignore_output = false; hide_cursor(); while (text[0] != '\0') { parse_character(text[0]); text++; } update_cursor(sScreen.x, sScreen.y); }
void setup_percents(void) { if (opt.flags & OPT_PERCENTS) { /* NB: we don't use _fileno() cause it is not in ISO C90, and so * is incompatible with the GCC -ansi option */ if (rhash_data.log == stderr && isatty(2)) { /* use one-line percents by default on console */ percents_output = &p_perc; IF_WINDOWS(hide_cursor()); } else { /* print percents as dots */ percents_output = &dots_perc; } } else { percents_output = &dummy_perc; /* no percents */ } }
void remember_screen() { unsigned char* src = (unsigned char*)0xd800; unsigned char* dst = curr_screen_colors(); hide_cursor(); tidy_up_colors(); while (src != (unsigned char*)0xd800 + 40 * 25) { // Pack nibbles. unsigned char packed = *src & 0xf; ++src; packed |= *src << 4; ++src; *dst = packed; ++dst; } memcpy(curr_screen_chars(), DISPLAY_BASE, 40 * 25); *curr_bg_color() = (*(char*)0xd020 << 4) | (0xf & *(char*)0xd021); }