static void even( void ) { register F26Dot6 e1; F26Dot6 old; old = e1 = pop(); e1 = do_round(e1); assert( (e1&63L) == 0 ); /* e1 is an integer */ *stack_ptr = (e1&64) == 0; iprintf(( "even: (%ld) => %s\n", e1, *stack_ptr ? "TRUE" : "FALSE" )); stack_ptr++; } /* even() */
int main(int argc, const char **argv) { int min = 3, rest = 60; if (argc < 3) { usage(); return 1; } min = atoi(argv[1]); rest = atoi(argv[2]); srand(time(NULL)); total_punches = 0; while (1) { countdown(min, rest); do_round(min); sleep(rest); } return 0; }
void game_main_loop(Win *disp, Win *input) { int ret = 0; static char keybuf[32] = {0}; win_disp = disp; win_input = input; me.x = win_disp->locate.w / 2; me.y = win_disp->locate.h / 2; me.life = 1; me.face = 'X'; me.score = 0; round = 0; init_game(level); wclear(win_disp->win); draw(); do { round++; memset(keybuf, 0, sizeof(keybuf)); wait_user_cmd(keybuf, sizeof(keybuf)); ret = do_round(keybuf); if (ret == -1) { break; } if (ret == 0) { round = 0; init_game(++level); continue; } if (keybuf[0] == 'q') { break; } } while (strncmp(keybuf, "quit", 4) != 0); }
/*! \brief Really do combat once fighters have been inited * * \param bg Background image * \param mus Music * \param is_rnd If !=0 then this is a random combat * \returns 1 if battle occurred */ static int do_combat (char *bg, char *mus, int is_rnd) { int zoom_step; in_combat = 1; backart = load_datafile_object (PCX_DATAFILE, bg); if (is_rnd) { if ((numchrs == 1) && (pidx[0] == AYLA)) { hs = rand () % 100 + 1; ms = rand () % 3 + 1; } else { if (numchrs > 1 && (in_party (AYLA) > 0)) { hs = rand () % 20 + 1; ms = rand () % 5 + 1; } else { hs = rand () % 10 + 1; ms = rand () % 10 + 1; } } } else { hs = 10; ms = 10; } /* RB: do the zoom at the beginning of the combat. */ pause_music (); set_music_volume ((gmvol / 250.0) * 0.75); play_music (mus, 0); if (stretch_view == 2) { do_transition (TRANS_FADE_OUT, 2); clear_bitmap (double_buffer); do_transition (TRANS_FADE_IN, 64); } else /* TT TODO: * Change this so when we zoom into the battle, it won't just zoom into the middle * of the screen. Instead, it's going to zoom into the location where the player * is, so if he's on the side of the map somewhere... */ for (zoom_step = 0; zoom_step < 9; zoom_step++) { poll_music (); /* RB FIXME: stretching when 640x480, stretching when 320x240? */ /* shouldn't one of those be the "common" size, and */ /* therefore not needing to stretch it? */ /* 320x240 is the double_buffer size... */ if (stretch_view == 1) stretch_blit (double_buffer, screen, zoom_step * 16 + xofs, zoom_step * 12 + yofs, 320 - (zoom_step * 32), 240 - (zoom_step * 24), 0, 0, 640, 480); else stretch_blit (double_buffer, screen, zoom_step * 16 + xofs, zoom_step * 12 + yofs, 320 - (zoom_step * 32), 240 - (zoom_step * 24), 0, 0, 320, 240); /* RB FIXME: should we vsync here rather than rest? */ kq_wait (100); } snap_togrid (); roll_initiative (); curx = 0; cury = 0; vspell = 0; combatend = 0; /* RB: execute combat */ do_round (); unload_datafile_object (backart); set_music_volume (gmvol / 250.0); resume_music (); if (alldead) stop_music (); steps = 0; in_combat = 0; timer_count = 0; return (1); }
int main(int argc, char *argv[]) { struct rusage begin, end; struct itimerval timer; struct trace *trace; struct index *idx; int ch, ret; time_t secs = DEFAULT_SECS; size_t round; while ((ch = getopt(argc, argv, "qt:")) != -1) { switch (ch) { case 'q': quiet = true; break; case 't': secs = atoi(optarg); if (secs <= 0) usage(); break; default: usage(); /* NOTREACHED */ } } argc -= optind; argv += optind; if (argc != 1) usage(); errno = 0; trace = trace_load(argv[0]); if (trace == NULL) err(1, "trace_load"); idx = index_new(); if (idx == NULL) errx(1, "index_new failed"); timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; timer.it_value.tv_sec = secs; timer.it_value.tv_usec = 0; signal(SIGPROF, do_stop); round = 0; stop = 0; setitimer(ITIMER_PROF, &timer, NULL); getrusage(RUSAGE_SELF, &begin); do { ret = do_round(idx, trace); if (ret != 0) errx(1, "failed in round %zu", round); round++; } while (!stop); getrusage(RUSAGE_SELF, &end); stats(&begin, &end, round); return 0; }