void draw_visible_stars(cv::Mat image, cv::Mat catalog) const { // For each entry in the catalog for (int i = 0; i < catalog.rows; i++) { float mag = catalog.at<float>(i, 0); double ra = catalog.at<float>(i, 1); double de = catalog.at<float>(i, 2); // Translate star by current attitude ra = angle_modulo(ra - attitude_ra, 0, 2*M_PI); de = angle_modulo(de - attitude_de, -M_PI, M_PI); // If star is visible if (is_star_visible(ra, de)) { const double x = camera_x_offset + screen_distance * tan(ra); const double y = camera_y_offset + screen_distance * tan(de); // Convert between: // Origin in the center, (x,y) in meters // Origin in the corner, (x_screen,y_screen) in pixels const int x_screen = round(-x / screen_horizontal_pixel_size + screen_width / 2); const int y_screen = round(-y / screen_vertical_pixel_size + screen_height / 2); draw_star(image, x_screen, y_screen, mag); } } }
static void redraw_stars_bitmap (struct star s[], struct stars_bitmap *sb, int count, enum vm vm) { int i; for (i = 0; i < count; i++) draw_star (&s[i], sb, vm); }
/** * Draws all currently visible stars onto the buffer. */ void draw_starfield(BITMAP *buffer) { for (int a = 0; a < STAR_AMOUNT; ++a) { if (starfield[a].vis == FALSE) { continue; } draw_star(buffer, starfield[a].xpos, starfield[a].ypos, starfield[a].c); } }
static void starfield_move_and_draw(struct starfield * starfield) { int i; for(i=0;i<starfield->nb_stars;++i) { move_star(&(starfield->tab[i]), starfield->z_move); draw_star(&(starfield->tab[i]), starfield->z_move); } }
static void draw_stars (ALLEGRO_BITMAP *bitmap, struct star s[], struct stars_bitmap *sb, size_t count, enum vm vm) { if (anim_cycle % 4) { draw_bitmapc (sb->b, bitmap, &sb->c, 0); return; } int i = prandom (count - 1); s[i].color = next_color (s[i].color); draw_star (&s[i], sb, vm); draw_bitmapc (sb->b, bitmap, &sb->c, 0); }
static void draw_stars (ALLEGRO_BITMAP *bitmap, struct stars *stars, enum vm vm) { if (! stars->count) return; if (anim_cycle % 4 || game_paused) { draw_bitmapc (stars->b, bitmap, &stars->c, 0); return; } int i = prandom (stars->count - 1); stars->s[i].color = next_color (stars->s[i].color); draw_star (stars, i, vm); draw_bitmapc (stars->b, bitmap, &stars->c, 0); }
// seg001:00E6 void __pascal far draw_proom_drects() { draw_princess_room_bg(); #ifdef USE_FADE if (!is_global_fading) { #endif while (drects_count--) { copy_screen_rect(&drects[drects_count]); } #ifdef USE_FADE } #endif drects_count = 0; if (cutscene_wait_frames & 1) { draw_star(prandom(N_STARS - 1), 1); } }
// seg001:0CCD void __pascal far load_intro(int which_imgs,cutscene_ptr_type func,int free_sounds) { short current_star; draw_rect(&screen_rect, 0); if (free_sounds) { free_optional_sounds(); } free_all_chtabs_from(id_chtab_3_princessinstory); load_chtab_from_file(id_chtab_8_princessroom, 950, "PV.DAT", 1<<13); load_chtab_from_file(id_chtab_9_princessbed, 980, "PV.DAT", 1<<14); current_target_surface = offscreen_surface; method_6_blit_img_to_scr(get_image(id_chtab_8_princessroom, 0), 0, 0, 0); method_6_blit_img_to_scr(get_image(id_chtab_9_princessbed, 0), 0, 142, blitters_2_or); // Free the images that are not needed anymore. free_all_chtabs_from(id_chtab_9_princessbed); SDL_FreeSurface(get_image(id_chtab_8_princessroom, 0)); if (NULL != chtab_addrs[id_chtab_8_princessroom]) chtab_addrs[id_chtab_8_princessroom]->images[0] = NULL; load_chtab_from_file(id_chtab_3_princessinstory, 800, "PV.DAT", 1<<9); load_chtab_from_file(id_chtab_4_jaffarinstory_princessincutscenes, 50*which_imgs + 850, "PV.DAT", 1<<10); for (current_star = 0; current_star < N_STARS; ++current_star) { draw_star(current_star, 0); } current_target_surface = onscreen_surface_; while (check_sound_playing()) { idle(); do_paused(); delay_ticks(1); } need_drects = 1; reset_cutscene(); is_cutscene = 1; func(); is_cutscene = 0; free_all_chtabs_from(3); draw_rect(&screen_rect, 0); }
int uHTRPowerMezzMenu::start_test(char *responce) { if (n_checks_ < 0) return -1; int key_code; char resp; if(( key_code = getch()) == ERR) { return 0; } else { n_checks_ = shutdown_time_; *responce = key_code; char buff[64]; switch(key_code) { case KEY_DOWN: ++selected_board_; if(selected_board_ == boards_.end()) selected_board_ = boards_.begin(); draw_star(); break; case KEY_UP: if(selected_board_ == boards_.begin()) { selected_board_ = boards_.end(); --selected_board_; } else --selected_board_; draw_star(); break; case 'q': return -1; break; case 's': case 't': query_server(&selected_board_->second); if(selected_board_->second.pid != 0 ) break; sprintf(buff,"Start test on board %d [y,N]: ",selected_board_->first); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); resp = readch(); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(resp != 'y') break; if(key_code == 's') { sprintf(buff,"Enter name[%s]:",tester); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); char tstr[64]; readstr(tstr); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(strlen(tstr) != 0) { sprintf(tester,"%s",tstr); } else if (strlen(tester) == 0) { sprintf(buff,"Tester must be set to start test"); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); break; } selected_board_->second.mezzanines->labelAll(tester,"MINNESOTA"); usleep(100000); } if(fork() == 0) return selected_board_->first; break; case 'k': //Check if Process exists //if not ask to cleanup board if(selected_board_->second.pid == 0) break; if(kill(selected_board_->second.pid,0)) { sprintf(buff,"PID %d not found. Cleanup? [Y/n]",selected_board_->second.pid); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); resp = readch(); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(resp == KEY_ENTER || resp == 'y') { //selected_board_->second.mezzanines->setPrimaryLoad(false, false); //selected_board_->second.mezzanines->setSecondaryLoad(false, false, false, false); //selected_board_->second.mezzanines->setRun(false); selected_board_->second.s20->stopTest(); } } else { sprintf(buff,"Kill test on board %d (pid %d) [y,N]:",selected_board_->first,selected_board_->second.pid); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); resp = readch(); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(resp != 'y') break; if (kill(selected_board_->second.pid,SIGINT)) { sprintf(buff,"Failed to kill %d pid with SIGINT. Force test to stop? [y/N]", selected_board_->second.pid); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); resp = readch(); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(resp != 'y') break; if(kill(selected_board_->second.pid,SIGKILL)) { sprintf(buff,"Failed to kill %d pid with SIGKILL. You might need help.", selected_board_->second.pid); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); } //selected_board_->second.mezzanines->setPrimaryLoad(false, false); //selected_board_->second.mezzanines->setSecondaryLoad(false, false, false, false); //selected_board_->second.mezzanines->setRun(false); } } //break; // Purposeful flowthrough to 'd' DO NOT place anything between 'k' and 'd' case 'd': io::printf("Disabling board %d", selected_board_->first); selected_board_->second.mezzanines->disableMezzanines(); break; case 'g': /*sprintf(buff,"Start test on all idle boards[y,N]:"); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); resp = readch(); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(resp != 'y') break; { sprintf(buff,"Enter name[%s]:",tester); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); char tstr[64]; readstr(tstr); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(strlen(tstr) != 0) { sprintf(tester,"%s",tstr); } else if (strlen(tester) == 0) { sprintf(buff,"Tester must be set to start test"); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); break; } query_servers(); for(std::map<int,Board>::iterator board = boards_.begin(); board != boards_.end(); board++) { if(board->second.pid != 0 || !board->second.isConnected) continue; board->second.mezzanines->labelAll(tester,"Minnesota"); pid_t pid = fork(); if(pid == 0) return board->first; } }*/ break; case 'r': query_server(&selected_board_->second); if(selected_board_->second.pid != 0 ) { selected_board_->second.mezzanines->printMezzMAC(); } else { io::set_wait(true); selected_board_->second.mezzanines->readEeprom(); io::set_wait(false); } break; case 'w': { query_server(&selected_board_->second); if(selected_board_->second.pid != 0 ) break; sprintf(buff,"Enter name[%s]:",tester); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); char tstr[64]; readstr(tstr); sprintf(buff," "); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); if(strlen(tstr) != 0) { sprintf(tester,"%s",tstr); } else if (strlen(tester) == 0) { sprintf(buff,"Tester must be set to start test"); mvaddstr(yinit_ + 5 + boards_.size(),xinit_ + 2,buff); break; } selected_board_->second.mezzanines->labelAll(tester,"Minnesota"); } break; case 'p': break; case '?': io::set_wait(true); io::printf("**************Controls*****************"); io::printf("'Up/Down' - Change selected board"); io::printf("'s' - Start Short Test on selected board"); io::printf("'t' - Start Long Test on selected board"); io::printf("'k' - Kill Test on selected board"); io::printf("'d' - Disable selected board WITHOUT ASKING ANY QUESTIONS!"); io::printf("'r' - Read EEPROM on selected board"); io::printf("'w' - Write EEPROM on selected board"); io::printf("'p' - Print Mac Addresses"); //io::printf("'p' - Program EEPROM on all idle boards"); //io::printf("'g' - Start all idle boards (Go)"); io::printf("'q' - Quit"); io::set_wait(false); default: break; } return 0; } }
static void redraw_stars_bitmap (struct stars *stars, enum vm vm) { int i; for (i = 0; i < stars->count; i++) draw_star (stars, i, vm); }
bool_t draw_space( bool_t flg_draw_staff_roll ) { long sx, sy, sw, sh; long mx, my; long fl; long max_n, i; move_space(); g_frame++; do { if( !flg_draw_staff_roll ) break; if( get_scene() != SCENE_N_ENDING_STAFF_ROLL ) break; if( (g_frame % g_roll_frame_n) != 0 ) break; staff_roll_y += 1; wipe_all(); break; } while( 0 ); sx = 0; sy = 0; sw = SCREEN_WIDTH; sh = SCREEN_HEIGHT; mx = sx + sw / 2; my = sy + sh / 2; max_n = get_star_n(); fl = max_n / FLICKER_N; if( fl < 1 ) fl = 1; for( i = 0; i < max_n; i++ ){ long drx, dry; long zz; zz = g_space.star[i].z + 1; drx = mx + g_space.star[i].x / zz / 16; dry = my + g_space.star[i].y / zz / 32; wipe_star( g_space.star[i].drx, g_space.star[i].dry ); if( dry < sh ) draw_star( drx, dry, zz ); g_space.star[i].drx = drx; g_space.star[i].dry = dry; if( (i % fl) == 0 ) if( flg_draw_staff_roll ) draw_staff_roll(); } if( flg_draw_staff_roll ) draw_staff_roll(); set_crsr( 0, 0 ); sleep_msec( 100 ); return TRUE; }