/** Resets the system to its start state. */ void StellaEnvironment::reset() { m_state.resetEpisodeFrameNumber(); // Reset the paddles m_state.resetPaddles(m_osystem->event()); // Reset the emulator m_osystem->console().system().reset(); // NOOP for 60 steps in the deterministic environment setting, or some random amount otherwise int noopSteps; noopSteps = 60; emulate(PLAYER_A_NOOP, PLAYER_B_NOOP, noopSteps); // reset for n steps emulate(RESET, PLAYER_B_NOOP, m_num_reset_steps); // reset the rom (after emulating, in case the NOOPs led to reward) m_settings->reset(); // Apply necessary actions specified by the rom itself ActionVect startingActions = m_settings->getStartingActions(); for (size_t i = 0; i < startingActions.size(); i++) { emulate(startingActions[i], PLAYER_B_NOOP); } }
int eval (int a) { emulate (a, 0); int r1 = eval (); emulate (a, 1); int r2 = eval (); return max (r1, r2); }
// This method is cloned from Operator, just resetting sign and exception bits // (because we don't have any exception support in this toy example) TestCase* FPSumOf3Squares::buildRandomTestCase(int i){ TestCase *tc; /* Generate test cases using random input numbers */ tc = new TestCase(this); // TODO free all this memory when exiting TestBench /* Fill inputs */ for (unsigned int j = 0; j < ioList_.size(); j++) { Signal* s = ioList_[j]; if (s->type() == Signal::in) { // ****** Modification: positive normal numbers with small exponents mpz_class m = getLargeRandom(wF); mpz_class bias = (mpz_class(1)<<(wE-1)) - 1; mpz_class e = getLargeRandom(wE-2) - (mpz_class(1)<<(wE-3)) + bias; // ensure no overflow mpz_class a = (mpz_class(1)<<(wE+wF+1)) // 01 to denote a normal number + (e<<wF) + m; tc->addInput(s->getName(), a); } } /* Get correct outputs */ emulate(tc); // cout << tc->getInputVHDL(); // cout << tc->getExpectedOutputVHDL(); return tc; }
void program_main(const argdata_t *ad) { // Extract executable file descriptor and argument data from sequence. argdata_seq_iterator_t it; argdata_seq_iterate(ad, &it); const argdata_t *fdv, *argv; int fd; if (!argdata_seq_next(&it, &fdv) || argdata_get_fd(fdv, &fd) != 0 || !argdata_seq_next(&it, &argv)) _Exit(127); // Serialize argument data that needs to be passed to the executable. size_t buflen, fdslen; argdata_get_buffer_length(argv, &buflen, &fdslen); int *fds = malloc(fdslen * sizeof(fds[0]) + buflen); if (fds == NULL) _Exit(127); void *buf = &fds[fdslen]; fdslen = argdata_get_buffer(argv, buf, fds); // Register file descriptors. struct fd_table ft; fd_table_init(&ft); for (size_t i = 0; i < fdslen; ++i) if (!fd_table_insert_existing(&ft, i, fds[i])) _Exit(127); // Start emulation. emulate(fd, buf, buflen, &posix_syscalls); _Exit(127); }
int main(int argc, char* argv[]) { get_scenes(data); if (argc>1) { FILE* fr = fopen(SAVEFILE, "r"); if (!fr) { printf("Can't open %s for loading savestate", SAVEFILE); return 1; } printf("emulating\n"); int i=0; char l[20]; save = malloc(sizeof(int)*80); while(fgets(l, 20, fr) != NULL) { sscanf(l, "%d", &save[i]); i++; } save[i]=0; /*i=0; printf("scanned: "); while (save[i]) { printf("%d", save[i]); i++; } printf("\n");*/ fclose(fr); emulate(); } rew(data); read(data); freeall(*data); return 0; }
void EmuThread::run() { setTerminationEnabled(); path_boot1 = boot1.c_str(); path_flash = flash.c_str(); int ret = emulate(port_gdb, port_rdbg); emit exited(ret); }
static msg_t eeThread(void *arg) { chRegSetThreadName("Engine"); while (TRUE) { while (!flag) chThdSleepMilliseconds(200); flag = FALSE; emulate(); } #if defined __GNUC__ return (msg_t)NULL; #endif }
void profile(struct emu_config *conf, struct connection *con, void *data, unsigned int size, unsigned int offset) { struct emu *e = emu_new(); struct emu_env *env = emu_env_new(e); env->profile = emu_profile_new(); // struct emu_cpu *cpu = emu_cpu_get(e); struct emu_memory *mem = emu_memory_get(e); emu_cpu_reg32_set(emu_cpu_get(e), esp, 0x0012fe98); emu_memory_write_block(mem, CODE_OFFSET, data, size); emu_cpu_eip_set(emu_cpu_get(e), CODE_OFFSET + offset); run(e, env); bool needemu = false; struct emu_profile_function *function; for( function = emu_profile_functions_first(env->profile->functions); !emu_profile_functions_istail(function); function = emu_profile_functions_next(function) ) { if( strcmp("recv", function->fnname) == 0 ) { g_message("Can not profile %s, emulating instead", function->fnname); needemu = true; } } if( needemu == true ) { emulate(conf, con, data, size, offset); } else { GString *str = g_string_new(NULL); json_profile_debug(env->profile, str); //printf("%s", str->str); struct incident *i = incident_new("dionaea.module.emu.profile"); incident_value_string_set(i, "profile", str); incident_value_con_set(i, "con", con); connection_ref(con); GAsyncQueue *aq = g_async_queue_ref(g_dionaea->threads->cmds); g_async_queue_push(aq, async_cmd_new(async_incident_report, i)); g_async_queue_unref(aq); ev_async_send(g_dionaea->loop, &g_dionaea->threads->trigger); } emu_env_free(env); emu_free(e); }
/** Applies the given actions (e.g. updating paddle positions when the paddle is used) * and performs one simulation step in Stella. */ reward_t StellaEnvironment::oneStepAct(Action player_a_action, Action player_b_action) { // Once in a terminal state, refuse to go any further (special actions must be handled // outside of this environment; in particular reset() should be called rather than passing // RESET or SYSTEM_RESET. if (isTerminal()) return 0; // Convert illegal actions into NOOPs; actions such as reset are always legal noopIllegalActions(player_a_action, player_b_action); // Emulate in the emulator emulate(player_a_action, player_b_action); // Increment the number of frames seen so far m_state.incrementFrame(); return m_settings->getReward(); }
int main () { n = getN (); for (int i = 0; i <= n; i++) state[i] = 2; int code = curpos (); while (code < 0) { int mr = 1000000; int mi; for (int a = 0; a <= 60; a++) { int c = eval (a); if (c < mr) mr = c, mi = a; } int x = query (mi + 1); emulate (mi, x); memcpy (state, state2, sizeof state); code = curpos (); } answer (code + 1); /* while (l < r) { int k = (l + r) / 2; int a = query (k + 1); if (!lied) { int a2 = query (k + 1); if (a != a2) { a = query (k + 1); lied = true; } } if (a == 1) r = k; else l = k + 1; } answer (l + 1); */ return 0; }
int main(int argc, char *argv[]) { smn8_rom rom; const char *filename; FILE *fp; int ret; if(argc > 1) { if(*argv[1] == '-') return print_version_or_usage((const char **) argv); filename = argv[1]; } else { #ifdef __EMSCRIPTEN__ filename = "roms/TETRIS"; #else filename = NULL; #endif } if(filename != NULL) { fp = fopen(filename, "rb"); if(fp == NULL) { fprintf(stderr, "Could not open ROM '%s'.\n", filename); return EXIT_FAILURE; } } else { fp = stdin; } ret = smn8_rom_load(&rom, fp) ? emulate(&rom) : EXIT_FAILURE; if(argc > 1 && fp != NULL) fclose(fp); return ret; }
/* ======================================================================== main: This is the main entry point for the VirtualT application. ======================================================================== */ int main(int argc, char **argv) { if (process_args(argc, argv)) /* Parse command line args */ return 1; setup_working_path(argv); /* Create a working dir path */ setup_unix_signals(); /* Setup Unix signal handling */ // Added by JV for prefs init_pref(); /* load user Menu preferences */ check_installation(); /* Test if install needs to be performed */ load_setup_preferences(); /* Load user Peripheral setup preferences */ load_memory_preferences(); /* Load user Memory setup preferences */ load_remote_preferences(); /* Load user Remote Socket preferences */ /* Perform initialization */ init_mem(); /* Initialize Memory */ init_io(); /* Initialize I/O structures */ init_sound(); /* Initialize Sound system */ init_display(); /* Initialize the Display */ init_cpu(); /* Initialize the CPU */ init_throttle_timer(); /* Initialize the throttle timer */ init_remote(); /* Initialize the remote control */ init_lpt(); /* Initialize the printer subsystem */ init_other_windows(); /* Initialize other windows that were opened (memedit, regs, etc. */ get_model_time(); /* Load the emulated time for current model */ /* Perform Emulation */ emulate(); /* Main emulation loop */ /* Save RAM contents after emulation */ save_ram(); save_model_time(); /* Save the emulated time */ /* Cleanup */ deinit_io(); /* Deinitialize I/O */ deinit_sound(); /* Deinitialize sound */ deinit_lpt(); /* Deinitialize the printer */ deinit_throttle_timer(); /* Deinitialize the throttle timer */ deinit_display(); /* Deinitialze and free the main window */ free_mem(); /* Free memory used by ReMem and/or Rampac */ return 0; }
void FixComplexKCM::buildStandardTestCases(TestCaseList * tcl) { TestCase* tc; int one = 1; if(lsb_in < 0 && msb_in >= 0) { //Real one one = one << -lsb_in; } tc = new TestCase(this); tc->addInput("ReIN", 0); tc->addInput("ImIN", 0); emulate(tc); tcl->add(tc); tc = new TestCase(this); tc->addInput("ReIN", one); tc->addInput("ImIN", 0); emulate(tc); tcl->add(tc); tc = new TestCase(this); tc->addInput("ReIN", 0); tc->addInput("ImIN", one); emulate(tc); tcl->add(tc); tc = new TestCase(this); tc->addInput("ReIN", one); tc->addInput("ImIN", one); emulate(tc); tcl->add(tc); if(signedInput) { tc = new TestCase(this); tc->addInput("ReIN", -1 * one); tc->addInput("ImIN", -1 * one); emulate(tc); tcl->add(tc); } tc = new TestCase(this); tc->addInput("ReIN", 2 * one); tc->addInput("ImIN", 0); emulate(tc); tcl->add(tc); }
int main(int argc, char **argv) { memory_t *mem; FILE *fin; FILE *fout; int verbose; int limit; if (argc < 3) { fprintf(stderr, "%s", USAGE); exit(1); } verbose = is_verbose(argc, argv); limit = step_limit(argc, argv); if (!strcmp(argv[1], "emulate")) { fin = fopen(argv[2], "r"); mem = read_machine_code(fin, verbose); emulate(mem, verbose, limit); free_mem(mem); fclose(fin); } else if (!strcmp(argv[1], "assemble")) { if (argc < 4) { fprintf(stderr, "Not enough arguments to assemble\n"); exit(1); } fin = fopen(argv[2], "r"); fout = fopen(argv[3], "w"); assemble(fin, fout, verbose); fclose(fout); fclose(fin); } else { printf("Unknown command %s\n", argv[1]); } return 0; }
int main(int argc, char *argv[]) { if (argc < 2) { printf( "usage: %s CMD [OPTIONS]\n" " CMD can be one of:\n\n" " probe IP PORT Start TCP SYN+ACK RTT probes and write measurements data to STDOUT\n" " emulate Read measurement data from STDIN and configure Kernel (tc-netem(8)) on-the-fly.\n" " This mode only uses the mean and standard deviation of of the previous samples\n" " to configure the netem qdisc. This can be used to interactively replicate a network link.\n" "\n" " dist generate Read measurement data from STDIN and write distribution file to STDOUT (see /usr/lib/tc/*.dist)\n" " dist load Read measurement data from STDIN and configure Kernel (tc-netem(8))\n" " These modes generate an inverse cumulated probability function (CDF) from the previously\n" " recorded measurements. This iCDF can either be used by tc(8) or 'netem table'\n" "\n" " OPTIONS:\n\n" " -m --mark N apply emulation only to packet buffers with mark N\n" " -M --mask N an optional mask for the fw mark\n" " -i --interval N update the emulation parameters every N seconds\n" " -r --rate rate limit used for measurements and updates of network emulation\n" " -l --limit how many probes should we sent\n" " -d --dev network interface\n" "\n" "netem util %s (built on %s %s)\n" " Copyright 2015, Steffen Vogel <*****@*****.**>\n", argv[0], VERSION, __DATE__, __TIME__); exit(EXIT_FAILURE); } /* Setup signals */ struct sigaction sa_quit = { .sa_flags = SA_SIGINFO, .sa_sigaction = quit }; sigemptyset(&sa_quit.sa_mask); sigaction(SIGTERM, &sa_quit, NULL); sigaction(SIGINT, &sa_quit, NULL); /* Initialize PRNG for TCP sequence nos */ srand(time(NULL)); /* Parse Arguments */ char c, *endptr; while ((c = getopt (argc-1, argv+1, "h:m:M:i:l:d:r:")) != -1) { switch (c) { case 'm': cfg.mark = strtoul(optarg, &endptr, 0); goto check; case 'M': cfg.mask = strtoul(optarg, &endptr, 0); goto check; case 'i': cfg.interval = strtoul(optarg, &endptr, 10); goto check; case 'r': cfg.rate = strtof(optarg, &endptr); goto check; case 'l': cfg.limit = strtoul(optarg, &endptr, 10); goto check; case 'd': cfg.dev = strdup(optarg); break; case '?': if (optopt == 'c') error(-1, 0, "Option -%c requires an argument.", optopt); else if (isprint(optopt)) error(-1, 0, "Unknown option '-%c'.", optopt); else error(-1, 0, "Unknown option character '\\x%x'.", optopt); exit(EXIT_FAILURE); default: abort(); } continue; check: if (optarg == endptr) error(-1, 0, "Failed to parse parse option argument '-%c %s'", c, optarg); } char *cmd = argv[1]; if (!strcmp(cmd, "probe")) return probe(argc-optind-1, argv+optind+1); else if (!strcmp(cmd, "emulate")) return emulate(argc-optind-1, argv+optind+1); else if (!strcmp(cmd, "dist")) return dist(argc-optind-1, argv+optind+1); else error(-1, 0, "Unknown command: %s", cmd); return 0; }
int main(int argc, char **argv) { char **t; int t0; #ifdef USE_LOCALE setlocale(LC_ALL, ""); #endif #ifdef WINNT /* Do not use __try if compiling with MinGW */ #ifndef MINGW __try { #endif /* MINGW */ /* Start NT if we are compiling with MinGW, don't otherwise */ #ifdef MINGW nt_init(); #else //nt_init(); #endif /* MINGW */ fork_init(); /* Do not use __except if compiling with MinGW */ #ifndef MINGW }__except(1) { dprintf("damn 0x%08x\n",GetExceptionCode()); return 1; }; #endif /* MINGW */ #endif /* WINNT */ global_permalloc(); /* * Provisionally set up the type table to allow metafication. * This will be done properly when we have decided if we are * interactive */ typtab['\0'] |= IMETA; typtab[STOUC(Meta) ] |= IMETA; typtab[STOUC(Marker)] |= IMETA; for (t0 = (int)STOUC(Pound); t0 <= (int)STOUC(Nularg); t0++) typtab[t0] |= ITOK | IMETA; for (t = argv; *t; *t = metafy(*t, -1, META_ALLOC), t++); #ifndef WINNT if (!(zsh_name = strrchr(argv[0], '/'))) #else if (!(zsh_name = strrchr(argv[0], '/')) && !(zsh_name = strrchr(argv[0], '\\')) && !(zsh_name = strchr(argv[0],':')) // !(argv[0][1] ==':') ) #endif /* WINNT */ zsh_name = argv[0]; else zsh_name++; if (*zsh_name == '-') zsh_name++; fdtable_size = OPEN_MAX; fdtable = zcalloc(fdtable_size); emulate(zsh_name, 1); /* initialises most options */ opts[LOGINSHELL] = (**argv == '-'); opts[MONITOR] = 1; /* may be unset in init_io() */ opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid()); opts[USEZLE] = 1; /* may be unset in init_io() */ parseargs(argv); /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */ SHTTY = -1; init_io(); setupvals(); init_signals(); global_heapalloc(); run_init_scripts(); init_misc(); for (;;) { do loop(1,0); while (tok != ENDINPUT); if (!(isset(IGNOREEOF) && interact)) { #if 0 if (interact) fputs(islogin ? "logout\n" : "exit\n", shout); #endif zexit(lastval, 0); continue; } noexitct++; if (noexitct >= 10) { stopmsg = 1; zexit(lastval, 0); } zerrnam("zsh", (!islogin) ? "use 'exit' to exit." : "use 'logout' to logout.", NULL, 0); } return 0; /* WINNT change, patch I think */ }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG uMsg; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WndProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; OpenConsole(); if( !RegisterClassEx(&winClass) ) return E_FAIL; GetINIPath(); LoadSettings(); pcejin.aspectRatio = GetPrivateProfileInt("Video", "aspectratio", 0, IniName); pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName); WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName); WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName); g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", pcejin.versionName.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, WndX, WndY, 256, 232, NULL, NULL, hInstance, NULL ); if( g_hWnd == NULL ) return E_FAIL; ScaleScreen(pcejin.windowSize); soundInit(); LoadIniSettings(); InitSpeedThrottle(); RecentROMs.SetGUI_hWnd(g_hWnd); RecentROMs.SetID(RECENTROM_START); RecentROMs.SetMenuID(ID_FILE_RECENTROM); RecentROMs.SetType("ROM"); RecentROMs.MakeRecentMenu(hInstance); RecentROMs.GetRecentItemsFromIni(IniName, "General"); RecentMovies.SetGUI_hWnd(g_hWnd); RecentMovies.SetID(RECENTMOVIE_START); RecentMovies.SetMenuID(ID_MOVIE_RECENT); RecentMovies.SetType("Movie"); RecentMovies.MakeRecentMenu(hInstance); RecentMovies.GetRecentItemsFromIni(IniName, "General"); RecentLua.SetGUI_hWnd(g_hWnd); RecentLua.SetID(RECENTLUA_START); RecentLua.SetMenuID(ID_LUA_RECENT); RecentLua.SetType("Lua"); RecentLua.MakeRecentMenu(hInstance); RecentLua.GetRecentItemsFromIni(IniName, "General"); DirectDrawInit(); InitCustomControls(); InitCustomKeys(&CustomKeys); LoadHotkeyConfig(); LoadInputConfig(); DragAcceptFiles(g_hWnd, true); extern void Agg_init(); Agg_init(); if (osd) {delete osd; osd =NULL; } osd = new OSDCLASS(-1); di_init(); DWORD wmTimerRes; TIMECAPS tc; if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) { wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); timeBeginPeriod (wmTimerRes); } else { wmTimerRes = 5; timeBeginPeriod (wmTimerRes); } if (KeyInDelayMSec == 0) { DWORD dwKeyboardDelay; SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0); KeyInDelayMSec = 250 * (dwKeyboardDelay + 1); } if (KeyInRepeatMSec == 0) { DWORD dwKeyboardSpeed; SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0); KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5)); } if (KeyInRepeatMSec < (int)wmTimerRes) KeyInRepeatMSec = (int)wmTimerRes; if (KeyInDelayMSec < KeyInRepeatMSec) KeyInDelayMSec = KeyInRepeatMSec; hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); initialize(); if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd); if (RecentROMs.GetAutoLoad() && (!skipAutoLoadROM)) { ALoad(RecentROMs.GetRecentItem(0).c_str()); } //Intentionally does not prompt for a game if no game specified, user should be forced to autoload roms as well, for this to work properly if (RecentMovies.GetAutoLoad() && (!skipAutoLoadMovie)) { LoadMovie(RecentMovies.GetRecentItem(0).c_str(), 1, false, false); } if (RecentLua.GetAutoLoad() && (!skipAutoLoadLua)) { char temp [1024]; strcpy(temp, RecentLua.GetRecentItem(0).c_str()); HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), g_hWnd, (DLGPROC) LuaScriptProc); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp); } while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { emulate(); render(); } if(!pcejin.started) Sleep(1); } // shutDown(); timeEndPeriod (wmTimerRes); CloseAllToolWindows(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }
int main(int argc, char *argv[]) { u32 done; memset(&_ctx, 0x00, sizeof _ctx); ctx = &_ctx; parse_args(argc, argv); #if 0 u64 local_ptr; local_ptr = 0xdead0000dead0000ULL; ctx->reg[3][0] = (u32)(local_ptr >> 32); ctx->reg[3][1] = (u32)local_ptr; ctx->reg[4][0] = 0xdead0000; ctx->reg[4][1] = 0xdead0000; #endif ctx->ls = (u8*)malloc(LS_SIZE); if (ctx->ls == NULL) fail("Unable to allocate local storage."); memset(ctx->ls, 0, LS_SIZE); #if 0 wbe64(ctx->ls + 0x3f000, 0x100000000ULL); wbe32(ctx->ls + 0x3f008, 0x10000); wbe32(ctx->ls + 0x3e000, 0xff); #endif if (gdb_port < 0) { ctx->paused = 0; } else { gdb_init(gdb_port); ctx->paused = 1; gdb_signal(SIGABRT); } elf_load(elf_path); setup_context(); done = 0; while(done == 0) { if (ctx->paused == 0 || ctx->paused == 2) done = emulate(); // data watchpoints if (done == 2) { ctx->paused = 0; gdb_signal(SIGTRAP); done = 0; } if (done != 0) { printf("emulated() returned, sending SIGSEGV to gdb stub\n"); ctx->paused = 1; done = gdb_signal(SIGSEGV); } if (done != 0) { #ifdef STOP_DUMP_REGS dump_regs(); #endif #ifdef STOP_DUMP_LS dump_ls(); #endif } //if (ctx->paused == 1) gdb_handle_events(); } printf("emulate() returned. we're done!\n"); dump_ls(); free(ctx->ls); gdb_deinit(); return 0; }
int main(int argc, char** argv) { StackDescription stkd ; Analysis analysis ; ThermalData tdata ; SimResult_t (*emulate) (ThermalData*, StackDescription*, Analysis*) ; Error_t error ; // Checks if there are the all the arguments //////////////////////////////////////////////////////////////////////////// if (argc != 2) { fprintf(stderr, "Usage: \"%s file.stk\"\n", argv[0]) ; return EXIT_FAILURE ; } // Init StackDescription and parse the input file //////////////////////////////////////////////////////////////////////////// fprintf (stdout, "Preparing stk data ... ") ; fflush (stdout) ; init_stack_description (&stkd) ; init_analysis (&analysis) ; error = fill_stack_description (&stkd, &analysis, argv[1]) ; if (error != TDICE_SUCCESS) return EXIT_FAILURE ; if (analysis.AnalysisType == TDICE_ANALYSIS_TYPE_TRANSIENT) emulate = &emulate_step ; else if (analysis.AnalysisType == TDICE_ANALYSIS_TYPE_STEADY) emulate = &emulate_steady ; else { fprintf (stderr, "unknown analysis type!\n "); free_stack_description (&stkd) ; return EXIT_FAILURE ; } fprintf (stdout, "done !\n") ; // Generate output files //////////////////////////////////////////////////////////////////////////// // We use "% " as prefix for matlab compatibility (header will be a comment) error = generate_analysis_headers (&analysis, stkd.Dimensions, "% ") ; if (error != TDICE_SUCCESS) { fprintf (stderr, "error in initializing output files \n "); free_stack_description (&stkd) ; return EXIT_FAILURE ; } // Init thermal data and fill it using the StackDescription //////////////////////////////////////////////////////////////////////////// fprintf (stdout, "Preparing thermal data ... ") ; fflush (stdout) ; init_thermal_data (&tdata) ; error = fill_thermal_data (&tdata, &stkd, &analysis) ; if (error != TDICE_SUCCESS) { free_analysis (&analysis) ; free_stack_description (&stkd) ; return EXIT_FAILURE ; } fprintf (stdout, "done !\n") ; // Run the simulation and print the output //////////////////////////////////////////////////////////////////////////// clock_t Time = clock() ; SimResult_t sim_result ; do { sim_result = emulate (&tdata, &stkd, &analysis) ; if (sim_result == TDICE_STEP_DONE || sim_result == TDICE_SLOT_DONE) { fprintf (stdout, "%.3f ", get_simulated_time (&analysis)) ; fflush (stdout) ; generate_analysis_output (&analysis, stkd.Dimensions, tdata.Temperatures, TDICE_OUTPUT_INSTANT_STEP) ; } if (sim_result == TDICE_SLOT_DONE) { fprintf (stdout, "\n") ; generate_analysis_output (&analysis, stkd.Dimensions, tdata.Temperatures, TDICE_OUTPUT_INSTANT_SLOT) ; } } while (sim_result != TDICE_END_OF_SIMULATION) ; generate_analysis_output (&analysis, stkd.Dimensions, tdata.Temperatures, TDICE_OUTPUT_INSTANT_FINAL) ; fprintf (stdout, "emulation took %.3f sec\n", ( (double)clock() - Time ) / CLOCKS_PER_SEC ) ; // free all data //////////////////////////////////////////////////////////////////////////// free_thermal_data (&tdata) ; free_analysis (&analysis) ; free_stack_description (&stkd) ; return EXIT_SUCCESS ; }
void main(int argc, char **argv) { initialize(argc, argv); emulate(); }
// Start the emulator bool machine_emulate(char *device,FILE *verbose,void (*fp_event)(uint8_t event,uint8_t data)) { return emulate(device,data,sids,verbose,fp_event); }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG uMsg; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WndProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if( !RegisterClassEx(&winClass) ) return E_FAIL; GetINIPath(); OpenConsoleWindow = GetPrivateProfileBool("Display", "OpenConsoleWindow", true, IniName); if (OpenConsoleWindow) OpenConsole(); pcejin.aspectRatio = GetPrivateProfileBool("Video", "aspectratio", false, IniName); pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName); WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName); WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName); g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", pcejin.versionName.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, WndX, WndY, 348, 224, NULL, NULL, hInstance, NULL ); if( g_hWnd == NULL ) return E_FAIL; ScaleScreen((float)pcejin.windowSize); soundInit(); LoadIniSettings(); InitSpeedThrottle(); DirectDrawInit(); InitCustomControls(); InitCustomKeys(&CustomKeys); LoadHotkeyConfig(); LoadInputConfig(); DragAcceptFiles(g_hWnd, true); extern void Agg_init(); Agg_init(); if (osd) {delete osd; osd =NULL; } osd = new OSDCLASS(-1); di_init(); DWORD wmTimerRes; TIMECAPS tc; if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) { wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); timeBeginPeriod (wmTimerRes); } else { wmTimerRes = 5; timeBeginPeriod (wmTimerRes); } if (KeyInDelayMSec == 0) { DWORD dwKeyboardDelay; SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0); KeyInDelayMSec = 250 * (dwKeyboardDelay + 1); } if (KeyInRepeatMSec == 0) { DWORD dwKeyboardSpeed; SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0); KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5)); } if (KeyInRepeatMSec < (int)wmTimerRes) KeyInRepeatMSec = (int)wmTimerRes; if (KeyInDelayMSec < KeyInRepeatMSec) KeyInDelayMSec = KeyInRepeatMSec; hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); initialize(); if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd); while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { emulate(); render(); } if(!pcejin.started) Sleep(1); } // shutDown(); timeEndPeriod (wmTimerRes); CloseAllToolWindows(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }