void open_picovic () { struct vic20_config config = { .memory_expansion = have_memory_expansion, .memory_expansion_3k = have_memory_expansion_3k, .use_paddles = FALSE, .manual_screen_updates = FALSE, .frames_per_second = 50, .frame_interceptor = NULL }; struct vic20_config * cfg = malloc (sizeof (struct vic20_config)); memcpy (cfg, &config, sizeof (struct vic20_config)); joystick_open (); video_open (); video_map (); vic20_open (cfg); init_debugger (); } void close_picovic () { vic20_close (); video_close (); joystick_close (); }
void register_command(const char *name, debugger_function_t function, void *state) { if (gDebuggerList == 0) { init_debugger(); } debugger_command_t *command = malloc(sizeof(debugger_command_t)); command->name = name; command->function = function; command->state = state; if (gDebuggerList->count >= gDebuggerList->capacity) { gDebuggerList->commands = realloc(gDebuggerList->commands, sizeof(debugger_command_t *) * (gDebuggerList->capacity + 10)); gDebuggerList->capacity += 10; } gDebuggerList->count++; gDebuggerList->commands[gDebuggerList->count - 1] = command; }
static void launch_rom(GtkWidget *widget, gpointer data) { char *name, *name_aux; name_aux = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)); name = malloc(strlen(name_aux)+1); strcpy(name, name_aux); gtk_widget_destroy(GTK_WIDGET(data)); printf("Emulateur Nintendo64 (mupen64) version : %s\n", VERSION); if (rom_read(name)) { if(rom) { free(rom); rom = NULL; } if(ROM_HEADER) { free(ROM_HEADER); ROM_HEADER = NULL; } free(name); file_selection_launched = 0; return; } // checking 'debugger' option #ifdef DBG if (GTK_TOGGLE_BUTTON(button_debug)->active == 1) { init_debugger(); } #endif // creating emulation thread if (pthread_create(&thread_n64, NULL, main_thread, NULL)) printf("error: problem with thread_n64 creation.\n"); else printf("creation of the emulation thread... PID=%ld\n", thread_n64); }
/********************************************************************************************************* * emulation thread - runs the core */ m64p_error main_run(void) { VILimit = (float) GetVILimit(); VILimitMilliseconds = (double) 1000.0/VILimit; /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */ r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator"); /* set some other core parameters based on the config file values */ savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement")); savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot")); no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump"); /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */ event_initialize(); // initialize memory, and do byte-swapping if it's not been done yet if (g_MemHasBeenBSwapped == 0) { init_memory(1); g_MemHasBeenBSwapped = 1; } else { init_memory(0); } // Attach rom to plugins if (!romOpen_gfx()) { free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL; } if (!romOpen_audio()) { romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL; } if (!romOpen_input()) { romClosed_audio(); romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL; } if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay")) { // init on-screen display int width = 640, height = 480; readScreen(NULL, &width, &height, 0); // read screen to get width and height osd_init(width, height); } // setup rendering callback from video plugin to the core, for screenshots and On-Screen-Display setRenderingCallback(video_plugin_render_callback); #ifdef WITH_LIRC lircStart(); #endif // WITH_LIRC #ifdef DBG if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger")) init_debugger(); #endif /* Startup message on the OSD */ osd_new_message(OSD_MIDDLE_CENTER, "Mupen64Plus Started..."); g_EmulatorRunning = 1; StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING); /* call r4300 CPU core and run the game */ r4300_reset_hard(); r4300_reset_soft(); r4300_execute(); #ifdef WITH_LIRC lircStop(); #endif // WITH_LIRC #ifdef DBG if (g_DebuggerActive) destroy_debugger(); #endif if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay")) { osd_exit(); } romClosed_RSP(); romClosed_input(); romClosed_audio(); romClosed_gfx(); free_memory(); // clean up g_EmulatorRunning = 0; StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED); SDL_Quit(); return M64ERR_SUCCESS; }
/********************************************************************************************************* * emulation thread - runs the core */ m64p_error main_init(void) { size_t i; unsigned int disable_extra_mem; static int channels[] = { 0, 1, 2, 3 }; /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */ r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator"); /* set some other core parameters based on the config file values */ no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump"); disable_extra_mem = ConfigGetParamInt(g_CoreConfig, "DisableExtraMem"); #if 0 count_per_op = ConfigGetParamInt(g_CoreConfig, "CountPerOp"); #endif if (count_per_op <= 0) count_per_op = 2; /* do byte-swapping if it's not been done yet */ if (g_MemHasBeenBSwapped == 0) { swap_buffer(g_rom, 4, g_rom_size / 4); g_MemHasBeenBSwapped = 1; } if (g_DDMemHasBeenBSwapped == 0) { swap_buffer(g_ddrom, 4, g_ddrom_size / 4); g_DDMemHasBeenBSwapped = 1; } connect_all(&g_r4300, &g_dp, &g_sp, &g_ai, &g_pi, &g_ri, &g_si, &g_vi, &g_dd, g_rdram, (disable_extra_mem == 0) ? 0x800000 : 0x400000, g_rom, g_rom_size, g_ddrom, g_ddrom_size, g_dd_disk, g_dd_disk_size); init_memory(); // Attach rom to plugins printf("Gfx RomOpen.\n"); if (!gfx.romOpen()) { printf("Gfx RomOpen failed.\n"); return M64ERR_PLUGIN_FAIL; } printf("Input RomOpen.\n"); if (!input.romOpen()) { printf("Input RomOpen failed.\n"); gfx.romClosed(); return M64ERR_PLUGIN_FAIL; } /* connect external time source to AF_RTC component */ g_si.pif.af_rtc.user_data = NULL; g_si.pif.af_rtc.get_time = get_time_using_C_localtime; /* connect external game controllers */ for(i = 0; i < GAME_CONTROLLERS_COUNT; ++i) { g_si.pif.controllers[i].user_data = &channels[i]; g_si.pif.controllers[i].is_connected = egcvip_is_connected; g_si.pif.controllers[i].get_input = egcvip_get_input; } /* connect external rumblepaks */ for(i = 0; i < GAME_CONTROLLERS_COUNT; ++i) { g_si.pif.controllers[i].rumblepak.user_data = &channels[i]; g_si.pif.controllers[i].rumblepak.rumble = rvip_rumble; } /* connect saved_memory.mempacks to mempaks */ for(i = 0; i < GAME_CONTROLLERS_COUNT; ++i) { g_si.pif.controllers[i].mempak.user_data = NULL; g_si.pif.controllers[i].mempak.save = dummy_save; g_si.pif.controllers[i].mempak.data = &saved_memory.mempack[i][0]; } /* connect saved_memory.eeprom to eeprom */ g_si.pif.eeprom.user_data = NULL; g_si.pif.eeprom.save = dummy_save; g_si.pif.eeprom.data = saved_memory.eeprom; if (ROM_SETTINGS.savetype != EEPROM_16KB) { /* 4kbits EEPROM */ g_si.pif.eeprom.size = 0x200; g_si.pif.eeprom.id = 0x8000; } else { /* 16kbits EEPROM */ g_si.pif.eeprom.size = 0x800; g_si.pif.eeprom.id = 0xc000; } /* connect saved_memory.flashram to flashram */ g_pi.flashram.user_data = NULL; g_pi.flashram.save = dummy_save; g_pi.flashram.data = saved_memory.flashram; /* connect saved_memory.sram to SRAM */ g_pi.sram.user_data = NULL; g_pi.sram.save = dummy_save; g_pi.sram.data = saved_memory.sram; #ifdef DBG if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger")) init_debugger(); #endif g_EmulatorRunning = 1; StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING); /* call r4300 CPU core and run the game */ r4300_reset_hard(); r4300_reset_soft(); r4300_init(); return M64ERR_SUCCESS; }
/********************************************************************************************************* * emulation thread - runs the core */ m64p_error main_run(void) { DebugMessage(M64MSG_STATUS, "Main Run!"); VILimit = (float) GetVILimit(); VILimitMilliseconds = (double) 1000.0/VILimit; /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */ r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator"); /* set some other core parameters based on the config file values */ savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement")); savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot")); no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump"); /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */ event_initialize(); // initialize memory, and do byte-swapping if it's not been done yet if (g_MemHasBeenBSwapped == 0) { init_memory(1); g_MemHasBeenBSwapped = 1; } else { init_memory(0); } // Attach rom to plugins if (!romOpen_gfx()) { free_memory(); return M64ERR_PLUGIN_FAIL; } DebugMessage(M64MSG_STATUS, "Graphics Plugin Opened!"); if (!romOpen_audio()) { romClosed_gfx(); free_memory(); return M64ERR_PLUGIN_FAIL; } DebugMessage(M64MSG_STATUS, "Audio Plugin Opened!"); if (!romOpen_input()) { romClosed_audio(); romClosed_gfx(); free_memory(); return M64ERR_PLUGIN_FAIL; } DebugMessage(M64MSG_STATUS, "Input Plugin Opened!"); printf("Plugins opened!\n");fflush(stdout); #ifdef WITH_LIRC lircStart(); #endif // WITH_LIRC #ifdef DBG if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger")) init_debugger(); #endif //PumpEvents(); g_EmulatorRunning = 1; StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING); DebugMessage(M64MSG_STATUS, "Starting to reset r4300!");fflush(stdout); /* call r4300 CPU core and run the game */ r4300_reset_hard(); r4300_reset_soft(); DebugMessage(M64MSG_STATUS, "About to execute!"); fflush(stdout); r4300_execute(); #ifdef WITH_LIRC lircStop(); #endif // WITH_LIRC #ifdef DBG if (g_DebuggerActive) destroy_debugger(); #endif romClosed_RSP(); romClosed_input(); romClosed_audio(); romClosed_gfx(); free_memory(); // clean up g_EmulatorRunning = 0; StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED); //PDL_Quit(); SDL_Quit(); return M64ERR_SUCCESS; }