int main(int argc, char *argv[]) { avcodec_register_all(); av_log_set_level(AV_LOG_ERROR); bzero(&input_audio, sizeof(Track)); bzero(&input_video, sizeof(Track)); bzero(&output_audio, sizeof(output_audio)); bzero(&output_video, sizeof(output_video)); argc--; argv++; if(argc >= 2 && !strcmp(argv[0], "-d")) { debug_loop(argc, argv, loop); } else { loop(); } }
int main(int argc, char *argv[]) { char *rom_name; #ifdef __AMIGA__ BPTR file_lock = GetProgramDir(); SetProgramDir(file_lock); #endif signal(SIGSEGV, catch_me); #ifdef WII // SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); fatInitDefault(); #endif cf_init(); /* must be the first thing to do */ cf_init_cmd_line(); cf_open_file(NULL); /* Open Default configuration file */ rom_name=cf_parse_cmd_line(argc,argv); /* print effect/blitter list if asked by user */ if (!strcmp(CF_STR(cf_get_item_by_name("effect")),"help")) { print_effect_list(); exit(0); } if (!strcmp(CF_STR(cf_get_item_by_name("blitter")),"help")) { print_blitter_list(); exit(0); } init_sdl(); /* GP2X stuff */ #ifdef GP2X gp2x_init(); #endif if (gn_init_skin()!=SDL_TRUE) { printf("Can't load skin...\n"); exit(1); } reset_frame_skip(); if (conf.debug) conf.sound=0; /* Launch the specified game, or the rom browser if no game was specified*/ if (!rom_name) { // rom_browser_menu(); run_menu(); printf("GAME %s\n",conf.game); if (conf.game==NULL) return 0; } else { if (init_game(rom_name)!=SDL_TRUE) { printf("Can't init %s...\n",rom_name); exit(1); } } /* If asked, do a .gno dump and exit*/ if (CF_BOOL(cf_get_item_by_name("dump"))) { char dump[8+4+1]; sprintf(dump,"%s.gno",rom_name); dr_save_gno(&memory.rom,dump); close_game(); return 0; } if (conf.debug) debug_loop(); else main_loop(); close_game(); return 0; }
int main(int argc, char** argv) { int err; Tcl_Interp *interp; err = 0; print_head(); interp = Tcl_CreateInterp(); if (interp == NULL) { fprintf(stderr, "can't create interpreter\n"); return ERRCODE_TCL; } /* get device name from environment */ { char *denv; denv = getenv(ENV_DPORT_TTY); if (denv != NULL) strcpy(dev, denv); } /* check existance of default startup script */ { struct stat statbuf; if (stat(DEFAULT_SCRIPT, &statbuf) == 0) strcpy(script, DEFAULT_SCRIPT); } /* parse cmd line */ get_args(argc, argv, interp); if (strlen(dev) == 0) { fprintf(stderr, "communication port not specified, see --dev option\n"); return ERRCODE_DEVSTR; } /* print miscellaneous variables */ { if (strlen(script)) printf("SCRIPT %s\n", script); printf( "TTY %s\n", dev); printf("\n"); } /* initialize communication port */ commdev_init(); commdev_open(&commdev, dev); /* initialize some debug structures */ debug.commdev = &commdev; debug.interp = interp; debug.run = 1; debug.cont = 0; /* * Target's buffer size should be determined * befor we can execute some commands */ if (debug_cmd_get_bufsize(&debug) < 0) { err = ERRCODE_BUFSIZE; goto err_getbufsize; } if (Tcl_AppInit(interp) != TCL_OK) { err = ERRCODE_TCL; goto err_tcl; } err = debug_loop(); err_getbufsize: err_tcl: commdev_close(&commdev); commdev_exit(); return err; }
// we do integer maths here to avoid creeping // double-precision addition inaccuracies void loop_control( const char *name, loop_call_fn *fp, void *arg, int usec, int flags, int offset ) { int64_t timer, intv, nsec, offs, diff, t, skips, fires; int i, ticks = 1, curr = 0; struct timespec ts; #ifdef DEBUG_LOOPS int64_t marker = 1; #endif // convert to nsec nsec = 1000 * (int64_t) usec; offs = 1000 * (int64_t) offset; // the actual sleep interval may be less // if period is too high intv = nsec; // wind down to an acceptable interval // try to avoid issues while( ( flags & LOOP_TRIM ) && intv > MAX_LOOP_NSEC && intv > offs ) { for( i = 0; i < 8; i++ ) if( ( intv % loop_control_factors[i] ) == 0 ) break; // if we can't find a suitable factor then try 2 // this may introduce long-term instability :-( if( i == 8 ) { warn( "Could not find a suitable prime factor for %s interval nsec.", name ); i = 0; } // and adjust intv /= loop_control_factors[i]; ticks *= loop_control_factors[i]; } if( ticks > 1 ) debug( "Loop %s trimmed from %ld to %ld nsec interval.", name, nsec, intv ); // get the time clock_gettime( CLOCK_REALTIME, &ts ); timer = tsll( ts ); // do we synchronise to a clock? if( flags & LOOP_SYNC ) { t = timer + offs + nsec - ( timer % nsec ); diff = t - timer; timer = t; llts( diff, ts ); nanosleep( &ts, NULL ); debug( "Pushed paper for %d usec to synchronize %s loop.", diff / 1000, name ); } fires = 0; skips = 0; // say a loop has started loop_mark_start( name ); while( ctl->run_flags & RUN_LOOP ) { // decide if we are firing the payload if( ++curr == ticks ) { #ifdef DEBUG_LOOPS if( !( flags & LOOP_SILENT ) ) debug_loop( "Calling payload %s", name ); #endif (*fp)( timer, arg ); fires++; curr = 0; } // roll on the timer timer += intv; // get the current time clock_gettime( CLOCK_REALTIME, &ts ); t = tsll( ts ); // don't do negative sleep if( t < timer ) { // and sleep diff = timer - t; llts( diff, ts ); nanosleep( &ts, NULL ); } else { skips++; #ifdef DEBUG_LOOPS if( skips == marker ) { debug( "Loop %s skips: %ld", name, skips ); marker = marker << 1; } #endif } } // and say it's finished loop_mark_done( name, skips, fires ); }