void init(struct Game *g) { load_resources(g); start_sdl(g); }
int main(int argc, char **argv) { /* The Global MIPS State */ MIPS_state_t mips_state; rs232in_fd = rs232out_fd = -1; char *serial_input_file = NULL; char *serial_output_file = NULL; for (;;) { int c; int option_index = 0; c = getopt_long(argc, argv, "tf:i:o:", long_options, &option_index); if (c == -1) break; switch (c) { case 0: break; case 'f': printf("file %s\n", filename = optarg); break; case 'i': serial_input_file = optarg; break; case 'o': serial_output_file = optarg; break; case '?': usage(argv[0]); break; case 1000: icache_way_lines_log2 = atoi(optarg); break; case 1001: icache_words_in_line_log2 = atoi(optarg); break; case 1002: dcache_way_lines_log2 = atoi(optarg); break; case 1003: dcache_words_in_line_log2 = atoi(optarg); break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind >= argc) { usage(argv[0]); } while (optind < argc) { readelf(argv[optind++]); } int is_bidir = serial_output_file && serial_input_file && strcmp(serial_input_file, serial_output_file) == 0; if (serial_input_file) { printf("serial input %s\n", serial_input_file); rs232in_fd = open(serial_input_file, (is_bidir ? O_RDWR : O_RDONLY) | O_NONBLOCK); if (rs232in_fd < 0) perror(optarg), exit(1); { /* Turn off echo */ struct termios t; if (tcgetattr(rs232in_fd, &t)) /*perror("getattr")*/; else { t.c_lflag &= ~(ECHO|ECHOE|ECHOK); if (tcsetattr(rs232in_fd, TCSANOW, &t)) perror("setattr"); } } } if (serial_output_file && !is_bidir) { printf("serial output %s\n", serial_output_file); rs232out_fd = open(serial_output_file, O_WRONLY | O_NONBLOCK); if (rs232out_fd < 0) perror(optarg), exit(1); } if (is_bidir) rs232out_fd = rs232in_fd; gettimeofday(&stat_start_time, NULL); switch (run) { case '1': if (enable_graphics) start_sdl(); atexit(print_stats); signal(SIGINT, exit); mips_state.pc = program_entry; init_reg_use_map(); if (screen) { SDL_CreateThread((int (*)(void *))run_simple, &mips_state); mainloop(); } else run_simple(&mips_state); break; case 'b': case 'r': case 'd': case 'm': dump_cache_init_files(); break; case 't': dump_tinymon(); exit(0); default: printf("No XX-run option given\n"); exit(1); } if (enable_testcases) { printf("Test "); if (mips_state.r[7] == 0x1729) { printf("SUCCEED!\n"); exit(0); } else { printf("FAILED! r7 = 0x%08x != 0x1729\n", mips_state.r[7]); exit(1); } } exit(0); }