void snes_init() { memset(&Settings, 0, sizeof(Settings)); Settings.MouseMaster = TRUE; Settings.SuperScopeMaster = TRUE; Settings.JustifierMaster = TRUE; Settings.MultiPlayer5Master = TRUE; Settings.FrameTimePAL = 20000; Settings.FrameTimeNTSC = 16667; Settings.SixteenBitSound = TRUE; Settings.Stereo = TRUE; Settings.SoundPlaybackRate = 32000; Settings.SoundInputRate = 32000; Settings.SupportHiRes = TRUE; Settings.Transparency = TRUE; Settings.AutoDisplayMessages = TRUE; Settings.InitialInfoStringTimeout = 120; Settings.HDMATimingHack = 100; Settings.BlockInvalidVRAMAccessMaster = TRUE; Settings.StopEmulation = TRUE; Settings.WrongMovieStateProtection = TRUE; Settings.DumpStreamsMaxFrames = -1; Settings.StretchScreenshots = 1; Settings.SnapshotScreenshots = TRUE; Settings.SkipFrames = AUTO_FRAMERATE; Settings.TurboSkipFrames = 15; Settings.CartAName[0] = 0; Settings.CartBName[0] = 0; Settings.AutoSaveDelay = 1; CPU.Flags = 0; if (!Memory.Init() || !S9xInitAPU()) { Memory.Deinit(); S9xDeinitAPU(); fprintf(stderr, "[libsnes]: Failed to init Memory or APU.\n"); exit(1); } S9xInitSound(64, 0); S9xSetSoundMute(FALSE); S9xSetSamplesAvailableCallback(S9xAudioCallback, NULL); S9xSetRenderPixelFormat(RGB555); GFX.Pitch = 2048; GFX.Screen = (uint16*) calloc(1, GFX.Pitch * 512 * sizeof(uint16)); S9xGraphicsInit(); S9xInitInputDevices(); for (int i = 0; i < 2; i++) { S9xSetController(i, CTL_JOYPAD, i, 0, 0, 0); snes_devices[i] = SNES_DEVICE_JOYPAD; } S9xUnmapAllControls(); map_buttons(); }
void snes_init() { memset(&Settings, 0, sizeof(Settings)); Settings.MouseMaster = TRUE; Settings.SuperScopeMaster = TRUE; Settings.JustifierMaster = TRUE; Settings.MultiPlayer5Master = TRUE; Settings.FrameTimePAL = 20000; Settings.FrameTimeNTSC = 16667; Settings.SoundPlaybackRate = 32000; Settings.SoundInputRate = 32000; Settings.AutoDisplayMessages = TRUE; Settings.InitialInfoStringTimeout = 120; Settings.HDMATimingHack = 100; Settings.BlockInvalidVRAMAccessMaster = TRUE; Settings.CartAName[0] = 0; Settings.CartBName[0] = 0; Settings.AutoSaveDelay = 1; CPU.Flags = 0; if (!Memory.Init() || !S9xInitAPU()) { Memory.Deinit(); S9xDeinitAPU(); fprintf(stderr, "[libsnes]: Failed to init Memory or APU.\n"); exit(1); } S9xInitSound(16, 0); S9xSetSamplesAvailableCallback(S9xAudioCallback); S9xSetRenderPixelFormat(RGB555); GFX.Pitch = 2048; GFX.Screen = (uint16*) calloc(1, GFX.Pitch * 512 * sizeof(uint16)); S9xGraphicsInit(); S9xInitInputDevices(); for (int i = 0; i < 2; i++) { S9xSetController(i, CTL_JOYPAD, i, 0, 0, 0); snes_devices[i] = SNES_DEVICE_JOYPAD; } S9xUnmapAllControls(); map_buttons(); }
int main (int argc, char *argv[]) { struct sigaction sig_callback; g_thread_init (NULL); gdk_threads_init (); gtk_init (&argc, &argv); bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); ZeroMemory (&Settings, sizeof (Settings)); /* Allow original config file for backend settings */ S9xLoadConfigFiles (argv, argc); /* Perform our config here */ gui_config = new Snes9xConfig (); S9xInitInputDevices (); gui_config->load_config_file (); char *rom_filename = S9xParseArgs (argv, argc); S9xReportControllers (); if (!Memory.Init () || !S9xInitAPU ()) exit (3); g_set_application_name ("Snes9x"); top_level = new Snes9xWindow (gui_config); /* If we're going to fullscreen, do it before showing window to avoid flicker. */ if ((gui_config->full_screen_on_open && rom_filename) || (gui_config->fullscreen)) gtk_window_fullscreen (top_level->get_window ()); top_level->show (); S9xInitDisplay (argc, argv); Memory.PostRomInitFunc = S9xPostRomInit; S9xPortSoundInit (); gui_config->reconfigure (); top_level->update_accels (); Settings.Paused = TRUE; syncing = 0; idle_func_id = g_idle_add_full (IDLE_FUNC_PRIORITY, S9xIdleFunc, NULL, NULL); g_timeout_add (10000, S9xScreenSaverCheckFunc, NULL); S9xNoROMLoaded (); if (rom_filename) { if (S9xOpenROM (rom_filename) && gui_config->full_screen_on_open) gtk_window_unfullscreen (top_level->get_window()); } memset (&sig_callback, 0, sizeof (struct sigaction)); sig_callback.sa_handler = S9xTerm; sigaction (15 /* SIGTERM */, &sig_callback, NULL); sigaction (3 /* SIGQUIT */, &sig_callback, NULL); sigaction (2 /* SIGINT */, &sig_callback, NULL); if (gui_config->fullscreen) { gui_config->fullscreen = 0; needs_fullscreening = 1; } #ifdef USE_JOYSTICK gui_config->flush_joysticks (); #endif gtk_window_present (top_level->get_window ()); gdk_threads_lock (); gtk_main (); return 0; }
int main(int argc, char ** argv) { // Initialise SDL if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) DIE("SDL_Init: %s", SDL_GetError()); GL_Init(); //Init SDL_TTF to print text to the screen... if ( TTF_Init() ) { fprintf( stderr, "Error initializing SDL_ttf!\n" ); exit ( 1 ); } S9xInitDisplay(argc, argv); // Configure snes9x #if CONF_GUI OssoInit(); // Hildon-games-wrapper initialization. #endif S9xLoadConfig(argc, argv); // Load config files and parse cmd line. readOptions(); #if CONF_GUI OssoConfig(); // Apply specific hildon-games config. #endif // S9x initialization S9xInitDisplay(argc, argv); S9xInitAudioOutput(); S9xInitInputDevices(); while(1) { S9xInit(); S9xReset(); char * rom = romSelector(); S9xSetRomFile(rom); free(rom); // Load rom and related files: state, unfreeze if needed loadRom(); resumeGame(); // Late initialization sprintf(String, "DrNokSnes - %s", Memory.ROMName); S9xSetTitle(String); S9xHacksLoadFile(Config.hacksFile); if (!S9xGraphicsInit()) DIE("S9xGraphicsInit failed"); S9xAudioOutputEnable(true); SDL_PauseAudio(0); S9xVideoReset(); Config.running = true; do { frameSync(); // May block, or set frameskip to true. S9xMainLoop(); // Does CPU things, renders if needed. pollEvents(); //Ouch that this is going here... updateBindingMessage(); } while (Config.running); S9xVideoReset(); S9xGraphicsDeinit(); // Save state Memory.SaveSRAM(S9xGetFilename(FILE_SRAM)); pauseGame(); Memory.Deinit(); S9xDeinitAPU(); } // Deinitialization S9xAudioOutputEnable(false); S9xDeinitInputDevices(); S9xDeinitAudioOutput(); S9xDeinitDisplay(); // Late deinitialization S9xUnloadConfig(); #if CONF_GUI OssoDeinit(); #endif SDL_Quit(); return 0; }