int GetFile(char *szFileName, char *szParse=0,u32 flags=0) { cfgLoadStr("config","image",szFileName,"null"); if (strcmp(szFileName,"null")==0) { #if HOST_OS==OS_WINDOWS OPENFILENAME ofn; ZeroMemory( &ofn , sizeof( ofn)); ofn.lStructSize = sizeof ( ofn ); ofn.hwndOwner = NULL ; ofn.lpstrFile = szFileName ; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = "All\0*.*\0\0"; ofn.nFilterIndex =1; ofn.lpstrFileTitle = NULL ; ofn.nMaxFileTitle = 0 ; ofn.lpstrInitialDir=NULL ; ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ; if (GetOpenFileNameA(&ofn)) { //already there //strcpy(szFileName,ofn.lpstrFile); } #endif } return 1; }
bool naomi_cart_SelectFile(void* handle) { cfgLoadStr("config", "image", SelectedFile, "null"); #if HOST_OS == OS_WINDOWS if (strcmp(SelectedFile, "null") == 0) { OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hInstance = (HINSTANCE)GetModuleHandle(0); ofn.lpstrFile = SelectedFile; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = "*.lst\0*.lst\0\0"; ofn.nFilterIndex = 0; ofn.hwndOwner = (HWND)handle; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR; if (GetOpenFileName(&ofn) <= 0) return true; } #endif if (!naomi_cart_LoadRom(SelectedFile)) { cfgSaveStr("emu", "gamefile", "naomi_bios"); } else { cfgSaveStr("emu", "gamefile", SelectedFile); } printf("EEPROM file : %s.eeprom\n", SelectedFile); return true; }
s32 EXPORT_CALL GetEmuSetting(u32 sid,void* value) { wchar* sptr=(wchar*)value; u32* tptr=(u32*)value; switch(sid) { _esai_(DYNAREC_ENABLED,dynarec.Enable,1); _esai_(DYNAREC_CPPASS,dynarec.CPpass,1); _esai_(DYNAREC_SAFEMODE,dynarec.Safe,1); _esai_(DYNAREC_UCFPU,dynarec.UnderclockFpu,1); _esai_(DREAMCAST_CABLE,dreamcast.cable,3); _esai_(DREAMCAST_RTC,dreamcast.RTC,0xFFFFFFFF); _esai_(DREAMCAST_REGION,dreamcast.region,3); _esai_(DREAMCAST_BROADCAST,dreamcast.broadcast,4); _esai_(EMULATOR_ASTART,emulator.AutoStart,1); default: if (sid<NDCS_COUNT) { cfgLoadStr(_T("nullDC_plugins"),ndc_snames[sid-NDCS_PLUGIN_PVR],sptr,pluginDefaults[sid-NDCS_PLUGIN_PVR]); return rv_ok; } else return rv_error; } return rv_ok; }
//These are helpers , mainly :) s32 EXPORT_CALL cfgLoadInt(const wchar * Section, const wchar * Key,s32 Default) { wchar temp_d[30]; wchar temp_o[30]; swprintf(temp_d,L"%d",Default); cfgLoadStr(Section,Key,temp_o,temp_d); return _wtoi(temp_o); }
void LoadSettings() { #ifndef _ANDROID settings.dynarec.Enable = cfgLoadInt("config","Dynarec.Enabled", 1)!=0; settings.dynarec.idleskip = cfgLoadInt("config","Dynarec.idleskip",1)!=0; settings.dynarec.unstable_opt = cfgLoadInt("config","Dynarec.unstable-opt",0); //disable_nvmem can't be loaded, because nvmem init is before cfg load settings.dreamcast.cable = cfgLoadInt("config","Dreamcast.Cable",3); settings.dreamcast.RTC = cfgLoadInt("config","Dreamcast.RTC",GetRTC_now()); settings.dreamcast.region = cfgLoadInt("config","Dreamcast.Region",3); settings.dreamcast.broadcast = cfgLoadInt("config","Dreamcast.Broadcast",4); settings.aica.LimitFPS = cfgLoadInt("config","aica.LimitFPS",1); settings.aica.NoBatch = cfgLoadInt("config","aica.NoBatch",0); settings.aica.NoSound = cfgLoadInt("config","aica.NoSound",0); settings.rend.UseMipmaps = cfgLoadInt("config","rend.UseMipmaps",1); settings.rend.WideScreen = cfgLoadInt("config","rend.WideScreen",0); settings.pvr.subdivide_transp = cfgLoadInt("config","pvr.Subdivide",0); settings.pvr.ta_skip = cfgLoadInt("config","ta.skip",0); settings.pvr.rend = cfgLoadInt("config","pvr.rend",0); settings.pvr.MaxThreads = cfgLoadInt("config", "pvr.MaxThreads", 3); settings.pvr.SynchronousRendering = cfgLoadInt("config", "pvr.SynchronousRendering", 0); settings.debug.SerialConsole = cfgLoadInt("config", "Debug.SerialConsoleEnabled", 0) != 0; settings.reios.ElfFile = cfgLoadStr("reios", "ElfFile",""); settings.validate.OpenGlChecks = cfgLoadInt("validate", "OpenGlChecks", 0) != 0; #endif settings.bios.UseReios = cfgLoadInt("config", "bios.UseReios", 0); #if (HOST_OS != OS_LINUX || defined(_ANDROID) || defined(TARGET_PANDORA)) settings.aica.BufferSize=2048; #else settings.aica.BufferSize=1024; #endif /* //make sure values are valid settings.dreamcast.cable = min(max(settings.dreamcast.cable, 0),3); settings.dreamcast.region = min(max(settings.dreamcast.region, 0),3); settings.dreamcast.broadcast= min(max(settings.dreamcast.broadcast,0),4); */ }
bool CreateGUI() { wchar gui[128]; cfgLoadStr(_T("nullDC_plugins"),_T("GUI"),gui,_T("nullDC_GUI_Win32.dll")); if (!OpenAndLoadGUI(gui)) { if (msgboxf(_T("Do you want to load default gui ?"),MBX_YESNO) == MBX_RV_YES) { if (!OpenAndLoadGUI(_T("nullDC_GUI_Win32.dll"))) return false; else return true; } else return false; } else return true; }
int GetFile(char *szFileName, char *szParse=0,u32 flags=0) { cfgLoadStr("config","image",szFileName,"null"); if (strcmp(szFileName,"null")==0) { #if defined(OMAP4) strcpy(szFileName,GetPath("/gdimage/crazy_taxi.chd").c_str()); #else #if HOST_OS==OS_WINDOWS OPENFILENAME ofn; ZeroMemory( &ofn , sizeof( ofn)); ofn.lStructSize = sizeof ( ofn ); ofn.hwndOwner = NULL ; ofn.lpstrFile = szFileName ; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = "All\0*.*\0\0"; ofn.nFilterIndex =1; ofn.lpstrFileTitle = NULL ; ofn.nMaxFileTitle = 0 ; ofn.lpstrInitialDir=NULL ; ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ; if (GetOpenFileNameA(&ofn)) { //already there //strcpy(szFileName,ofn.lpstrFile); } #else strcpy(szFileName,GetPath("/game.chd").c_str()); #endif #endif } if (strcmp(szFileName,"hardpath")==0) { strcpy(szFileName,"D:\\DC\\shenmue.chd"); } return 1; }
/* Loads a joystick map from a section in the configuration file */ void load_joystick_map(joystick_map & js_map, char const * section_name) { // Initialize the file descriptor for the current joystick in case // no joystick is found js_map.js.file_descriptor = -1; if (cfgOpen()) { // Find the desired controller's name char target_name[128]; cfgLoadStr(section_name, "controller.name", target_name, "None"); printf("Using following controller: %s\n", target_name); // We find the corresponding controller for (int i = 0; i <= 3; ++i) { // We check if the names match if (strcmp(js[i].name, target_name) == 0) { js_map.js = js[i]; // We erase the name so the same controller is not used twice js[i].name[0] = '\0'; // And we stop looking for other controllers break; } } if (js_map.js.file_descriptor < 0) { // If no controller was found, no need to load the configuration return; } // Loading axis mapping int id_axis_x = cfgLoadInt(section_name, "js.axis_x", -1); int id_axis_y = cfgLoadInt(section_name, "js.axis_y", -1); int id_axis_lt = cfgLoadInt(section_name, "js.axis_lt", -1); int id_axis_rt = cfgLoadInt(section_name, "js.axis_rt", -1); int id_axis_dpad_x = cfgLoadInt(section_name, "js.axis_dpad_x", -1); int id_axis_dpad_y = cfgLoadInt(section_name, "js.axis_dpad_y", -1); js_map.id_axis_x = id_axis_x; js_map.id_axis_y = id_axis_y; js_map.id_axis_lt = id_axis_lt; js_map.id_axis_rt = id_axis_rt; js_map.id_axis_dpad_x = id_axis_dpad_x; js_map.id_axis_dpad_y = id_axis_dpad_y; // Loading buttons mapping int button_A = cfgLoadInt(section_name, "js.button_A", -1); int button_B = cfgLoadInt(section_name, "js.button_B", -1); int button_C = cfgLoadInt(section_name, "js.button_C", -1); int button_X = cfgLoadInt(section_name, "js.button_X", -1); int button_Y = cfgLoadInt(section_name, "js.button_Y", -1); int button_Z = cfgLoadInt(section_name, "js.button_Z", -1); int button_start = cfgLoadInt(section_name, "js.button_start", -1); js_map.button_map[button_A] = Btn_A; js_map.button_map[button_B] = Btn_B; js_map.button_map[button_C] = Btn_C; js_map.button_map[button_X] = Btn_X; js_map.button_map[button_Y] = Btn_Y; js_map.button_map[button_Z] = Btn_Z; js_map.button_map[button_start] = Btn_Start; } }
// We're making these functions static - there's no need to pollute the global namespace static void alsa_init(audio_backend_pull_callback_t pull_callback) { snd_pcm_hw_params_t *params; unsigned int val; int dir=-1; string device = cfgLoadStr("alsa", "device", ""); int rc = -1; if (device == "" || device == "auto") { printf("ALSA: trying to determine audio device\n"); // trying default device device = "default"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); // "default" didn't work, try first device if (rc < 0) { device = "plughw:0,0,0"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); if (rc < 0) { device = "plughw:0,0"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); } } // first didn't work, try second if (rc < 0) { device = "plughw:1,0"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); } // try pulse audio backend if (rc < 0) { device = "pulse"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); } if (rc < 0) printf("ALSA: unable to automatically determine audio device.\n"); } else { rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); } if (rc < 0) { fprintf(stderr, "ALSA: unable to open PCM device %s: %s\n", device.c_str(), snd_strerror(rc)); return; } printf("ALSA: Successfully initialized \"%s\"\n", device.c_str()); /* Allocate a hardware parameters object. */ snd_pcm_hw_params_alloca(¶ms); /* Fill it in with default values. */ rc=snd_pcm_hw_params_any(handle, params); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_any %s\n", snd_strerror(rc)); return; } /* Set the desired hardware parameters. */ /* Interleaved mode */ rc=snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_access %s\n", snd_strerror(rc)); return; } /* Signed 16-bit little-endian format */ rc=snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_format %s\n", snd_strerror(rc)); return; } /* Two channels (stereo) */ rc=snd_pcm_hw_params_set_channels(handle, params, 2); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_channels %s\n", snd_strerror(rc)); return; } /* 44100 bits/second sampling rate (CD quality) */ val = 44100; rc=snd_pcm_hw_params_set_rate_near(handle, params, &val, &dir); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_rate_near %s\n", snd_strerror(rc)); return; } /* Set period size to settings.aica.BufferSize frames. */ period_size = settings.aica.BufferSize; rc=snd_pcm_hw_params_set_period_size_near(handle, params, &period_size, &dir); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_buffer_size_near %s\n", snd_strerror(rc)); return; } else { printf("ALSA: period size set to %ld\n", period_size); } buffer_size = (44100 * 100 /* settings.omx.Audio_Latency */ / 1000 / period_size + 1) * period_size; rc=snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_size); if (rc < 0) { fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_buffer_size_near %s\n", snd_strerror(rc)); return; } else { printf("ALSA: buffer size set to %ld\n", buffer_size); } /* Write the parameters to the driver */ rc = snd_pcm_hw_params(handle, params); if (rc < 0) { fprintf(stderr, "ALSA: Unable to set hw parameters: %s\n", snd_strerror(rc)); return; } }