void main_exit(void) { /* now begin to shut down */ #ifdef DBG if (g_DebuggerActive) destroy_debugger(); #endif rsp.romClosed(); input.romClosed(); gfx.romClosed(); // clean up g_EmulatorRunning = 0; StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED); }
/********************************************************************************************************* * 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_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; }