void init_current_effect(void) { // Disable flipping until first frame is drawn allow_flipping(false); /* Restore front and back buffer pointers to point to * different locations */ gs_restore_bufs(); // Set up rng srand_from_clock(); // Run initializer init_t init = (init_t)pgm_get(effect->init, word); if (init != NULL) init(); gs_buf_swap(); /* If NO_FLIP, we "broke" flipping if required by pointing * both buffers to the same location */ if (pgm_get(effect->flip_buffers, byte) == NO_FLIP) { gs_buf_back = gs_buf_front; } // Restart tick counter and FPS limiter reset_time(); next_draw_at = 0; }
void newGame () { music.stop(); music.openFromFile("./dati/audio/Morricone.ogg"); music.play(); main_camera.setLocRot(locRot(0,0,0,0,0,0)); int j; t=reset_time(t); for(j=0; j<18; j++){ m[j]=reset_motion(m[j]); } livello=1; // for the score score = 0; gun0.bullet_number = BULLET_NUMBER; first = TRUE; return; }
void chldreadcb(struct bufferevent *b, void *arg) { char *line, *sp, *ap; int n, i, nprocs = *(int *)arg; if((line=evbuffer_readline(b->input)) != nil){ sp = line; if((ap = strsep(&sp, "\t")) == nil) panic("report error\n"); n = atoi(ap); if(n - nreport > NBUFFER) panic("a process fell too far behind\n"); n %= NBUFFER; for(i=0; i<params.nbuckets + num_cols && (ap=strsep(&sp, "\t")) != nil; i++) reportbuf[n][i] += atoi(ap); if(++nreportbuf[n] >= nprocs){ /* Timestamp it. */ printf("%d\t",(int)time(nil)); for(i = 0; i < params.nbuckets + num_cols; i++) printf("%d\t", reportbuf[n][i]); printf("%ld\n", mkrate(&lastreporttv, reportbuf[n][0])); reset_time(&lastreporttv); /* Aggregate. */ counts.conn_successes += reportbuf[n][0]; counts.conn_errors += reportbuf[n][1]; counts.conn_timeouts += reportbuf[n][2]; counts.conn_closes += reportbuf[n][3]; counts.http_successes += reportbuf[n][4]; counts.http_errors += reportbuf[n][5]; for(i=0; i<params.nbuckets; i++) counts.counters[i] += reportbuf[n][i + num_cols]; /* Clear it. Advance nreport. */ memset(reportbuf[n], 0,(params.nbuckets + num_cols) * sizeof(int)); nreportbuf[n] = 0; nreport++; } free(line); } bufferevent_enable(b, EV_READ); }
PUBLIC void main() { mq_t *mq; int result; nw_init(); while (TRUE) { mq= mq_get(); if (!mq) ip_panic(("out of messages")); result= receive (ANY, &mq->mq_mess); if (result<0) { ip_panic(("unable to receive: %d", result)); } reset_time(); #if DEBUG & 256 { where(); printf("got message from %d, type %d\n", mq->mq_mess.m_source, mq->mq_mess.m_type); } #endif switch (mq->mq_mess.m_source) { case FS_PROC_NR: #if DEBUG & 256 { where(); printf("got message from fs, type %d\n", mq->mq_mess.m_type); } #endif sr_rec(mq); break; case DL_ETH: #if DEBUG & 256 { where(); printf("calling eth_rec\n"); } #endif eth_rec(&mq->mq_mess); mq_free(mq); break; case SYN_ALRM_TASK: clck_tick (&mq->mq_mess); mq_free(mq); break; default: ip_panic(("message from unknown source: %d", mq->mq_mess.m_source)); } } ip_panic(("task is not allowed to terminate")); }
// ----------------------------------------------------------------------------------------------------- //called when the player is starting a level (new game or new ship) StartLevel(int random) { Assert(!Player_is_dead); InitPlayerPosition(random); verify_console_object(); ConsoleObject->control_type = CT_FLYING; ConsoleObject->movement_type = MT_PHYSICS; disable_matcens(); clear_transient_objects(0); //0 means leave proximity bombs // create_player_appearance_effect(ConsoleObject); Do_appearance_effect = 1; #ifdef NETWORK if (Game_mode & GM_MULTI) { #ifndef SHAREWARE if (Game_mode & GM_MULTI_COOP) multi_send_score(); #endif multi_send_position(Players[Player_num].objnum); multi_send_reappear(); } if (Game_mode & GM_NETWORK) network_do_frame(1, 1); #endif ai_reset_all_paths(); ai_init_boss_for_ship(); reset_time(); reset_rear_view(); Auto_fire_fusion_cannon_time = 0; Fusion_charge = 0; Robot_firing_enabled = 1; if (VR_screen_mode == SCREEN_MENU) vr_reset_display(); }
void IgcReplay::Start() { if (Enabled) Stop(); if (!OpenFile()) { on_bad_file(); return; } cli.Reset(); reset_time(); on_reset(); Enabled = true; }
static int sandbox_i2c_rtc_xfer(struct udevice *emul, struct i2c_msg *msg, int nmsgs) { struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(emul); uint offset = 0; int ret; debug("\n%s\n", __func__); ret = sandbox_i2c_rtc_prepare_read(emul); if (ret) return ret; for (; nmsgs > 0; nmsgs--, msg++) { int len; u8 *ptr; len = msg->len; debug(" %s: msg->len=%d", msg->flags & I2C_M_RD ? "read" : "write", msg->len); if (msg->flags & I2C_M_RD) { debug(", offset %x, len %x: ", offset, len); /* Read the register */ memcpy(msg->buf, plat->reg + offset, len); memset(msg->buf + len, '\xff', msg->len - len); debug_buffer(0, msg->buf, 1, msg->len, 0); } else if (len >= 1) { ptr = msg->buf; offset = *ptr++ & (REG_COUNT - 1); len--; debug(", set offset %x: ", offset); debug_buffer(0, msg->buf, 1, msg->len, 0); /* Write the register */ memcpy(plat->reg + offset, ptr, len); if (offset == REG_RESET) reset_time(emul); } } ret = sandbox_i2c_rtc_complete_write(emul); if (ret) return ret; return 0; }
PUBLIC void main() { mq_t *mq; int r; int source, timerand, fd; struct fssignon device; #ifdef __minix_vmd struct systaskinfo info; #endif u8_t randbits[32]; struct timeval tv; #if DEBUG printf("Starting inet...\n"); printf("%s\n", version); #endif /* Read configuration. */ nw_conf(); /* Get a random number */ timerand= 1; fd= open(RANDOM_DEV_NAME, O_RDONLY | O_NONBLOCK); if (fd != -1) { r= read(fd, randbits, sizeof(randbits)); if (r == sizeof(randbits)) timerand= 0; else { printf("unable to read random data from %s: %s\n", RANDOM_DEV_NAME, r == -1 ? strerror(errno) : r == 0 ? "EOF" : "not enough data"); } close(fd); } else { printf("unable to open random device %s: %s\n", RANDOM_DEV_NAME, strerror(errno)); } if (timerand) { printf("using current time for random-number seed\n"); #ifdef __minix_vmd r= sysutime(UTIME_TIMEOFDAY, &tv); #else /* Minix 3 */ r= gettimeofday(&tv, NULL); #endif if (r == -1) { printf("sysutime failed: %s\n", strerror(errno)); exit(1); } memcpy(randbits, &tv, sizeof(tv)); } init_rand256(randbits); #ifdef __minix_vmd if (svrctl(SYSSIGNON, (void *) &info) == -1) pause(); /* Our new identity as a server. */ this_proc = info.proc_nr; #else /* Minix 3 */ /* Our new identity as a server. */ if ((this_proc = getprocnr()) < 0) ip_panic(( "unable to get own process nr\n")); #endif /* Register the device group. */ device.dev= ip_dev; device.style= STYLE_CLONE; if (svrctl(FSSIGNON, (void *) &device) == -1) { printf("inet: error %d on registering ethernet devices\n", errno); pause(); } #ifdef BUF_CONSISTENCY_CHECK inet_buf_debug= (getenv("inetbufdebug") && (strcmp(getenv("inetbufdebug"), "on") == 0)); inet_buf_debug= 100; if (inet_buf_debug) { ip_warning(( "buffer consistency check enabled" )); } #endif if (getenv("killerinet")) { ip_warning(( "killer inet active" )); killer_inet= 1; } #ifdef __minix_vmd r= sys_findproc(SYN_AL_NAME, &synal_tasknr, 0); if (r != OK) ip_panic(( "unable to find synchronous alarm task: %d\n", r )); #endif nw_init(); while (TRUE) { #ifdef BUF_CONSISTENCY_CHECK if (inet_buf_debug) { static int buf_debug_count= 0; if (++buf_debug_count >= inet_buf_debug) { buf_debug_count= 0; if (!bf_consistency_check()) break; } } #endif if (ev_head) { ev_process(); continue; } if (clck_call_expire) { clck_expire_timers(); continue; } mq= mq_get(); if (!mq) ip_panic(("out of messages")); r= receive (ANY, &mq->mq_mess); if (r<0) { ip_panic(("unable to receive: %d", r)); } reset_time(); source= mq->mq_mess.m_source; if (source == FS_PROC_NR) { sr_rec(mq); } #ifdef __minix_vmd else if (source == synal_tasknr) { clck_tick (&mq->mq_mess); mq_free(mq); } #else /* Minix 3 */ else if (mq->mq_mess.m_type == SYN_ALARM) { clck_tick(&mq->mq_mess); mq_free(mq); } else if (mq->mq_mess.m_type == SYS_SIG) { /* signaled */ /* probably SIGTERM */ mq_free(mq); } else if (mq->mq_mess.m_type & NOTIFY_MESSAGE) { /* A driver is (re)started. */ eth_check_drivers(&mq->mq_mess); mq_free(mq); } #endif else { compare(mq->mq_mess.m_type, ==, DL_TASK_REPLY); eth_rec(&mq->mq_mess); mq_free(mq); } } ip_panic(("task is not allowed to terminate")); }
//called when the player has died void DoPlayerDead() { int cycle_window_vis = 1; #ifdef NETWORK if ( (Game_mode & GM_MULTI) && (Netgame.SpawnStyle == SPAWN_STYLE_PREVIEW)) { cycle_window_vis = 0; } #endif if (Game_wind && cycle_window_vis) window_set_visible(Game_wind, 0); reset_palette_add(); gr_palette_load (gr_palette); dead_player_end(); //terminate death sequence (if playing) #ifdef EDITOR if (Game_mode == GM_EDITOR) { //test mine, not real level object * player = &Objects[Players[Player_num].objnum]; //nm_messagebox( "You're Dead!", 1, "Continue", "Not a real game, though." ); if (Game_wind) window_set_visible(Game_wind, 1); load_level("gamesave.lvl"); init_player_stats_new_ship(Player_num); player->flags &= ~OF_SHOULD_BE_DEAD; StartLevel(0); return; } #endif #ifdef NETWORK if ( Game_mode&GM_MULTI ) { multi_do_death(Players[Player_num].objnum); } else #endif { //Note link to above else! Players[Player_num].lives--; if (Players[Player_num].lives == 0) { DoGameOver(); return; } } if ( Control_center_destroyed ) { int rval; //clear out stuff so no bonus Players[Player_num].hostages_on_board = 0; Players[Player_num].energy = 0; Players[Player_num].shields = 0; #ifdef NETWORK Players[Player_num].connected = CONNECT_DIED_IN_MINE; #endif do_screen_message(TXT_DIED_IN_MINE); // Give them some indication of what happened if (Current_level_num == Last_level) { #ifdef NETWORK if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) { multi_endlevel_score(); rval = AdvanceLevel(0); //if finished, go on to next level } else #endif { // Note link to above else! rval = AdvanceLevel(0); //if finished, go on to next level DoEndLevelScoreGlitz(0); } init_player_stats_new_ship(Player_num); last_drawn_cockpit = -1; } else { #ifdef NETWORK if (Game_mode & GM_MULTI) multi_endlevel_score(); else #endif DoEndLevelScoreGlitz(0); // Note above link! rval = AdvanceLevel(0); //if finished, go on to next level init_player_stats_new_ship(Player_num); last_drawn_cockpit = -1; } if (rval) { #ifndef SHAREWARE if (PLAYING_BUILTIN_MISSION) #endif scores_maybe_add_player(0); if (Game_wind) window_close(Game_wind); // Exit out of game loop } } else { init_player_stats_new_ship(Player_num); StartLevel(1); } if (Game_wind && cycle_window_vis) window_set_visible(Game_wind, 1); reset_time(); }
//called when the player has finished a level void PlayerFinishedLevel(int secret_flag) { int rval; int was_multi = 0; if (Game_wind) window_set_visible(Game_wind, 0); //credit the player for hostages Players[Player_num].hostages_rescued_total += Players[Player_num].hostages_on_board; #ifndef SHAREWARE if (!(Game_mode & GM_MULTI) && (secret_flag)) { newmenu_item m[1]; m[0].type = NM_TYPE_TEXT; m[0].text = " "; //TXT_SECRET_EXIT; newmenu_do2(NULL, TXT_SECRET_EXIT, 1, m, NULL, NULL, 0, Menu_pcx_name); } #endif // -- mk mk mk -- used to be here -- mk mk mk -- #ifdef NETWORK if (Game_mode & GM_NETWORK) { if (secret_flag) Players[Player_num].connected = CONNECT_FOUND_SECRET; // Finished and went to secret level else Players[Player_num].connected = CONNECT_WAITING; // Finished but did not die } #endif last_drawn_cockpit = -1; if (Current_level_num == Last_level) { #ifdef NETWORK if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) { was_multi = 1; multi_endlevel_score(); rval = AdvanceLevel(secret_flag); //now go on to the next one (if one) } else #endif { // Note link to above else! rval = AdvanceLevel(secret_flag); //now go on to the next one (if one) DoEndLevelScoreGlitz(0); //give bonuses } } else { #ifdef NETWORK if (Game_mode & GM_MULTI) multi_endlevel_score(); else #endif // Note link!! DoEndLevelScoreGlitz(0); //give bonuses rval = AdvanceLevel(secret_flag); //now go on to the next one (if one) } if (!was_multi && rval) { #ifndef SHAREWARE if (PLAYING_BUILTIN_MISSION) #endif scores_maybe_add_player(0); if (Game_wind) window_close(Game_wind); // Exit out of game loop } else if (rval && Game_wind) window_close(Game_wind); if (Game_wind) window_set_visible(Game_wind, 1); reset_time(); }
void main(void) { mq_t *mq; int r; int source, m_type, timerand, fd; u32_t tasknr; struct fssignon device; u8_t randbits[32]; struct timeval tv; #if DEBUG printk("Starting inet...\n"); printk("%s\n", version); #endif #if HZ_DYNAMIC system_hz = sys_hz(); #endif /* Read configuration. */ nw_conf(); /* Get a random number */ timerand= 1; fd= open(RANDOM_DEV_NAME, O_RDONLY | O_NONBLOCK); if (fd != -1) { r= read(fd, randbits, sizeof(randbits)); if (r == sizeof(randbits)) timerand= 0; else { printk("inet: unable to read random data from %s: %s\n", RANDOM_DEV_NAME, r == -1 ? strerror(errno) : r == 0 ? "EOF" : "not enough data"); } close(fd); } else { printk("inet: unable to open random device %s: %s\n", RANDOM_DEV_NAME, strerror(errno)); } if (timerand) { printk("inet: using current time for random-number seed\n"); r= gettimeofday(&tv, NULL); if (r == -1) { printk("sysutime failed: %s\n", strerror(errno)); exit(1); } memcpy(randbits, &tv, sizeof(tv)); } init_rand256(randbits); /* Our new identity as a server. */ r= ds_retrieve_u32("inet", &tasknr); if (r != 0) ip_panic(("inet: ds_retrieve_u32 failed for 'inet': %d", r)); this_proc= tasknr; /* Register the device group. */ device.dev= ip_dev; device.style= STYLE_CLONE; if (svrctl(FSSIGNON, (void *) &device) == -1) { printk("inet: error %d on registering ethernet devices\n", errno); pause(); } #ifdef BUF_CONSISTENCY_CHECK inet_buf_debug= (getenv("inetbufdebug") && (strcmp(getenv("inetbufdebug"), "on") == 0)); inet_buf_debug= 100; if (inet_buf_debug) { ip_warning(( "buffer consistency check enabled" )); } #endif if (getenv("killerinet")) { ip_warning(( "killer inet active" )); killer_inet= 1; } nw_init(); while (TRUE) { #ifdef BUF_CONSISTENCY_CHECK if (inet_buf_debug) { static int buf_debug_count= 0; if (++buf_debug_count >= inet_buf_debug) { buf_debug_count= 0; if (!bf_consistency_check()) break; } } #endif if (ev_head) { ev_process(); continue; } if (clck_call_expire) { clck_expire_timers(); continue; } mq= mq_get(); if (!mq) ip_panic(("out of messages")); r = kipc_module_call(KIPC_RECEIVE, 0, ENDPT_ANY, &mq->mq_mess); if (r<0) { ip_panic(("unable to receive: %d", r)); } reset_time(); source= mq->mq_mess.m_source; m_type= mq->mq_mess.m_type; if (source == VFS_PROC_NR) { sr_rec(mq); } else if (is_notify(m_type)) { if (_ENDPOINT_P(source) == CLOCK) { clck_tick(&mq->mq_mess); mq_free(mq); } else if (_ENDPOINT_P(source) == PM_PROC_NR) { /* signaled */ /* probably SIGTERM */ mq_free(mq); } else { /* A driver is (re)started. */ eth_check_drivers(&mq->mq_mess); mq_free(mq); } } else if (m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY || m_type == DL_NAME_REPLY || m_type == DL_STAT_REPLY) { eth_rec(&mq->mq_mess); mq_free(mq); } else { printk("inet: got bad message type 0x%x from %d\n", mq->mq_mess.m_type, mq->mq_mess.m_source); mq_free(mq); } } ip_panic(("task is not allowed to terminate")); }
static int sandbox_i2c_rtc_bind(struct udevice *dev) { reset_time(dev); return 0; }
void main() { int i,j; UART1_Init(57600); Delay_ms(100); UART1_Write_Text("Start\n"); UART1_Write(13); UART1_Write(10); timer_setup(); UART1_Write_Text("timer started"); UART1_Write(13); UART1_Write(10); for( i = STOP; i > state_e; state_e++ ) // every state is being executed 1000 times except GRAPHICS, it is done 10 times { for( j = 0; j < 10000; j++ ) { switch( state_e ) { case DHRYSTONE: dhrystone_benchmark(); // after executing, record the time passed record_time(); reset_time(); break; case FFT: fft_benchmark(); record_time(); reset_time(); break; case WHETSTONE: whetstone_benchmark(); record_time(); reset_time(); timer_setup(); break; case GRAPHICS: { uint8_t temp; if ( j % 100 == 0) { for (temp = 0; temp <10; temp++) { graphics_benchmark(); record_time(); reset_time(); } } } break; } } } // print out the time passed UART1_Write_Text("Drhystone: "); IntToStr(dhrystone_time, txt); UART1_Write_Text(txt); UART1_Write(13); UART1_Write(10); UART1_Write_Text("FFT: "); IntToStr(fft_time, txt); UART1_Write_Text(txt); UART1_Write(13); UART1_Write(10); UART1_Write_Text("whetstone: "); IntToStr(whetstone_time, txt); UART1_Write_Text(txt); UART1_Write(13); UART1_Write(10); UART1_Write_Text("graphics: "); IntToStr(graphics_time, txt); UART1_Write_Text(txt); UART1_Write(13); UART1_Write(10); }
PUBLIC int main(int argc, char *argv[]) { mq_t *mq; int ipc_status; int r; endpoint_t source; int m_type; /* SEF local startup. */ sef_local_startup(); while (TRUE) { #ifdef BUF_CONSISTENCY_CHECK if (inet_buf_debug) { static int buf_debug_count= 0; if (++buf_debug_count >= inet_buf_debug) { buf_debug_count= 0; if (!bf_consistency_check()) break; } } #endif if (ev_head) { ev_process(); continue; } if (clck_call_expire) { clck_expire_timers(); continue; } mq= mq_get(); if (!mq) ip_panic(("out of messages")); r= sef_receive_status(ANY, &mq->mq_mess, &ipc_status); if (r<0) { ip_panic(("unable to receive: %d", r)); } reset_time(); source= mq->mq_mess.m_source; m_type= mq->mq_mess.m_type; if (source == VFS_PROC_NR) { sr_rec(mq); } else if (is_ipc_notify(ipc_status)) { if (source == CLOCK) { clck_tick(&mq->mq_mess); mq_free(mq); } else if (source == PM_PROC_NR) { /* signaled */ /* probably SIGTERM */ mq_free(mq); } else if (source == DS_PROC_NR) { /* DS notifies us of an event. */ ds_event(); mq_free(mq); } else { printf("inet: got unexpected notify from %d\n", mq->mq_mess.m_source); mq_free(mq); } } else if (m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY || m_type == DL_STAT_REPLY) { eth_rec(&mq->mq_mess); mq_free(mq); } else { printf("inet: got bad message type 0x%x from %d\n", mq->mq_mess.m_type, mq->mq_mess.m_source); mq_free(mq); } } ip_panic(("task is not allowed to terminate")); return 1; }