void osd_init(running_machine *machine) { // thread priority if (!options_get_bool(mame_options(), OPTION_DEBUG)) SetThreadPriority(GetCurrentThread(), options_get_int(mame_options(), WINOPTION_PRIORITY)); // ensure we get called on the way out add_exit_callback(machine, osd_exit); // initialize the subsystems winvideo_init(machine); winsound_init(machine); wininput_init(machine); winoutput_init(machine); // hook up the debugger log if (options_get_bool(mame_options(), WINOPTION_OSLOG)) add_logerror_callback(machine, output_oslog); // crank up the multimedia timer resolution to its max // this gives the system much finer timeslices timeresult = timeGetDevCaps(&caps, sizeof(caps)); if (timeresult == TIMERR_NOERROR) timeBeginPeriod(caps.wPeriodMin); // set our multimedia tasks if we can // if (av_set_mm_thread_characteristics != NULL) // mm_task = (*av_set_mm_thread_characteristics)(TEXT("Playback"), &task_index); start_profiler(); }
static int execute_simple_commands(core_options *options, const char *exename) { /* help? */ if (options_get_bool(options, CLIOPTION_HELP)) { display_help(); return MAMERR_NONE; } /* showusage? */ if (options_get_bool(options, CLIOPTION_SHOWUSAGE)) { mame_printf_info("Usage: %s [%s] [options]\n\nOptions:\n", exename, GAMENOUN); options_output_help(options, help_output); return MAMERR_NONE; } /* validate? */ if (options_get_bool(options, CLIOPTION_VALIDATE)) { extern int mame_validitychecks(const game_driver *driver); return mame_validitychecks(NULL); } return -1; }
kdfilter *kdfilter_new(apr_pool_t *pool) { kdfilter *self; apr_pool_t *obj_pool; const char *name = NULL; int spam_enabled, virus_enabled, from_enabled; apr_pool_create(&obj_pool, pool); self = apr_pcalloc(obj_pool, sizeof(kdfilter)); APR_RING_INIT(&self->filter_drv_list, filter_driver, link); /* Register cleanup function. */ apr_pool_cleanup_register(obj_pool, self, kdfilter_delete, kdfilter_delete); /* Add the default filters. */ do { /* Check if we enable the spam filter. */ spam_enabled = options_get_bool("filter_spam.enabled"); virus_enabled = options_get_bool("filter_virus.enabled"); from_enabled = options_get_bool("filter_spam.enabled"); if (from_enabled && kdfilter_add(self, &filter_from) < 0) { name = filter_from.filter_name; break; } if (spam_enabled && kdfilter_add(self, &filter_spam) < 0) { name = filter_spam.filter_name; break; } if (virus_enabled && kdfilter_add(self, &filter_virus) < 0) { name = filter_virus.filter_name; break; } if (kdfilter_add(self, &filter_forward) < 0) { name = filter_forward.filter_name; break; } self->pool = obj_pool; return self; } while (0); KERROR_PUSH(_filter_, 0, "filter %s failed initialization", name); apr_pool_destroy(obj_pool); return NULL; }
static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_info *window) { #if (SDL_VERSION_ATLEAST(1,3,0)) // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control if (!options_get_bool(mame_options(), OPTION_DEBUG)) { //FIXME: SDL1.3: really broken: the whole SDL code // will only work correct with relative mouse movements ... //SDL_SetRelativeMouseMode if (!window->fullscreen && !sdlinput_should_hide_mouse(machine)) { SDL_ShowCursor(SDL_ENABLE); if (SDL_GetWindowGrab(window->window_id )) SDL_SetWindowGrab(window->window_id, 0); } else { SDL_ShowCursor(SDL_DISABLE); if (!SDL_GetWindowGrab(window->window_id)) SDL_SetWindowGrab(window->window_id, 1); } SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility } #else // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control if (!options_get_bool(mame_options(), OPTION_DEBUG)) { if ( window->fullscreen || sdlinput_should_hide_mouse(machine) ) { SDL_ShowCursor(SDL_DISABLE); if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) { SDL_WM_GrabInput(SDL_GRAB_ON); } } else { SDL_ShowCursor(SDL_ENABLE); if (SDL_WM_GrabInput(SDL_GRAB_QUERY)) { SDL_WM_GrabInput(SDL_GRAB_OFF); } } } #endif }
/* Given an audio's file name, load lyrics from the default lyrics file name. */ void lyrics_autoload (const char *filename) { char *lyrics_filename, *extn; assert (!raw_lyrics); assert (lyrics_message); if (filename == NULL) { lyrics_message = "[No file playing!]"; return; } if (!options_get_bool ("AutoLoadLyrics")) { lyrics_message = "[Lyrics not autoloaded!]"; return; } if (is_url (filename)) { lyrics_message = "[Lyrics from URL is not supported!]"; return; } lyrics_filename = xstrdup (filename); extn = ext_pos (lyrics_filename); if (extn) { *--extn = '\0'; raw_lyrics = lyrics_load_file (lyrics_filename); } else lyrics_message = "[No lyrics file!]"; free (lyrics_filename); }
static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) { worker_param *wp = (worker_param *) param; sdl_window_info *window = wp->window; ASSERT_WINDOW_THREAD(); // if we are in debug mode, never go full screen if (options_get_bool(mame_options(), OPTION_DEBUG)) return NULL; // If we are going fullscreen (leaving windowed) remember our windowed size if (!window->fullscreen) { window->windowed_width = window->width; window->windowed_height = window->height; } window->destroy(window); sdlinput_release_keys(wp->machine); // toggle the window mode window->fullscreen = !window->fullscreen; complete_create_wt(param, 0); return NULL; }
void osd_init(running_machine *machine) { int watchdog = options_get_int(mame_options(), WINOPTION_WATCHDOG); const char *stemp; // thread priority if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)) SetThreadPriority(GetCurrentThread(), options_get_int(mame_options(), WINOPTION_PRIORITY)); // ensure we get called on the way out add_exit_callback(machine, osd_exit); // get number of processors stemp = options_get_string(mame_options(), WINOPTION_NUMPROCESSORS); osd_num_processors = 0; if (strcmp(stemp, "auto") != 0) { osd_num_processors = atoi(stemp); if (osd_num_processors < 1) { mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n"); osd_num_processors = 0; } } // initialize the subsystems winvideo_init(machine); winsound_init(machine); wininput_init(machine); winoutput_init(machine); // hook up the debugger log if (options_get_bool(mame_options(), WINOPTION_OSLOG)) add_logerror_callback(machine, output_oslog); // crank up the multimedia timer resolution to its max // this gives the system much finer timeslices timeresult = timeGetDevCaps(&caps, sizeof(caps)); if (timeresult == TIMERR_NOERROR) timeBeginPeriod(caps.wPeriodMin); // set our multimedia tasks if we can // if (av_set_mm_thread_characteristics != NULL) // mm_task = (*av_set_mm_thread_characteristics)(TEXT("Playback"), &task_index); start_profiler(); // if a watchdog thread is requested, create one if (watchdog != 0) { watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL); assert_always(watchdog_reset_event != NULL, "Failed to create watchdog reset event"); watchdog_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL); assert_always(watchdog_exit_event != NULL, "Failed to create watchdog exit event"); watchdog_thread = CreateThread(NULL, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, NULL); assert_always(watchdog_thread != NULL, "Failed to create watchdog thread"); } }
kdldap_servers *kdldap_servers_new(apr_pool_t *pool, int use_sasl) { apr_pool_t *obj_pool; kdldap_servers *self; const char *ldap_dom, *ldap_ad_site; apr_pool_create(&obj_pool, pool); self = apr_pcalloc(obj_pool, sizeof(kdldap_servers)); self->use_sasl = use_sasl; /* Get the AD forest to query. */ ldap_dom = options_get_str("ldap.domain"); if (ldap_dom == NULL || strlen(ldap_dom) == 0) self->ad_forest = NULL; else self->ad_forest = apr_pstrdup(obj_pool, ldap_dom); ldap_ad_site = options_get_str("ldap.ad_site"); if (ldap_ad_site == NULL || strlen(ldap_ad_site) == 0) self->ad_site = NULL; else self->ad_site = apr_pstrdup(obj_pool, ldap_ad_site); /* Check if we were told to search in the DNS. */ if (!self->ad_forest || options_get_bool("ldap.domain_search") <= 0) { WARN(_log_ldap_, "LDAP server search will use static server list."); self->use_dns = 0; } else self->use_dns = 1; if (self->use_dns) { if ((self->ad_forest && self->use_dns) && !self->ad_site) WARN(_log_ldap_, "No AD site defined. LDAP server queries will be done forest-wide."); else INFO(_log_ldap_, "AD site: %s.", self->ad_site); } /* Parse the static server list. */ if (!self->use_dns) { if (kdldap_servers_load_static_servers(self, obj_pool, &self->static_ldap_servers) < 0) { KERROR_PUSH(_ldap_, 0, "error loading static LDAP server list"); apr_pool_destroy(obj_pool); return NULL; } } else { /* ADNS initialization. */ if (adns_init(&self->adns_state, adns_if_noenv, 0)) { self->adns_init = 0; KERROR_SET(_ldap_, 0, "cannot initialize adns"); apr_pool_destroy(obj_pool); return NULL; } else self->adns_init = 1; } apr_pool_cleanup_register(obj_pool, self, kdldap_servers_cleanup, kdldap_servers_cleanup); return self; }
int running_machine::run(bool firstrun) { int error = MAMERR_NONE; /* move to the init phase */ m_current_phase = MACHINE_PHASE_INIT; /* then finish setting up our local machine */ start(); /* load the configuration settings and NVRAM */ config_load_settings(this); nvram_load(this); sound_mute(this, FALSE); /* display the startup screens */ ui_display_startup_screens(this, firstrun, !options_get_bool(&m_options, OPTION_SKIP_NAGSCREEN)); /* perform a soft reset -- this takes us to the running phase */ soft_reset(); /* run the CPUs until a reset or exit */ m_hard_reset_pending = false; while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE) return 0; return 0; }
int sdlwindow_init(running_machine *machine) { // determine if we are using multithreading or not multithreading_enabled = options_get_bool(mame_options(), SDLOPTION_MULTITHREADING); // get the main thread ID before anything else main_threadid = SDL_ThreadID(); // ensure we get called on the way out add_exit_callback(machine, sdlwindow_exit); // if multithreading, create a thread to run the windows if (multithreading_enabled) { // create a thread to run the windows from #ifndef SDLMAME_OS2 work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); #else work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); #endif if (work_queue == NULL) return 1; osd_work_item_queue(work_queue, &sdlwindow_thread_id, NULL, WORK_ITEM_FLAG_AUTO_RELEASE); } else { // otherwise, treat the window thread as the main thread //window_threadid = main_threadid; sdlwindow_thread_id(NULL, 0); } // initialize the drawers #if USE_OPENGL if (video_config.mode == VIDEO_MODE_OPENGL) { if (drawogl_init(&draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif #if SDL_VERSION_ATLEAST(1,3,0) if (video_config.mode == VIDEO_MODE_SDL13) { if (draw13_init(&draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif if (video_config.mode == VIDEO_MODE_SOFT) { if (drawsdl_init(&draw)) return 1; } // set up the window list last_window_ptr = &sdl_window_list; return 0; }
void sound_init(running_machine *machine) { attotime update_frequency = SOUND_UPDATE_FREQUENCY; const char *filename; /* handle -nosound */ nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND); if (nosound_mode) Machine->sample_rate = 11025; /* count the speakers */ for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ; VPRINTF(("total speakers = %d\n", totalspeakers)); /* allocate memory for mix buffers */ leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix)); rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix)); finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix)); /* allocate a global timer for sound timing */ sound_update_timer = timer_alloc(sound_update, NULL); timer_adjust(sound_update_timer, update_frequency, 0, update_frequency); /* initialize the streams engine */ VPRINTF(("streams_init\n")); streams_init(machine, update_frequency.attoseconds); /* now start up the sound chips and tag their streams */ VPRINTF(("start_sound_chips\n")); start_sound_chips(); /* then create all the speakers */ VPRINTF(("start_speakers\n")); start_speakers(); /* finally, do all the routing */ VPRINTF(("route_sound\n")); route_sound(); /* open the output WAV file if specified */ filename = options_get_string(mame_options(), OPTION_WAVWRITE); if (filename[0] != 0) wavfile = wav_open(filename, machine->sample_rate, 2); /* enable sound by default */ global_sound_enabled = TRUE; sound_muted = FALSE; sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME)); /* register callbacks */ config_register("mixer", sound_load, sound_save); add_pause_callback(machine, sound_pause); add_reset_callback(machine, sound_reset); add_exit_callback(machine, sound_exit); }
const char *image_get_device_option(device_image_interface *image) { const char *result = NULL; if (options_get_bool(&image->device().machine->options(), OPTION_ADDED_DEVICE_OPTIONS)) { /* access the option */ result = options_get_string_priority(&image->device().machine->options(), image->image_config().instance_name(), OPTION_PRIORITY_DRIVER_INI); } return result; }
static void handle_arg(core_options *copts, const char *arg) { int this_test_count; int this_failure_count; struct messtest_options opts; /* setup options */ memset(&opts, 0, sizeof(opts)); opts.script_filename = arg; if (options_get_bool(copts, "preservedir")) opts.preserve_directory = 1; if (options_get_bool(copts, "dumpscreenshots")) opts.dump_screenshots = 1; if (messtest(&opts, &this_test_count, &this_failure_count)) exit(-1); test_count += this_test_count; failure_count += this_failure_count; }
struct loaded_samples *readsamples(const char *const *samplenames, const char *basename) { struct loaded_samples *samples; int skipfirst = 0; int i; /* if the user doesn't want to use samples, bail */ if (!options_get_bool(mame_options(), OPTION_SAMPLES)) return NULL; if (samplenames == 0 || samplenames[0] == 0) return NULL; /* if a name begins with '*', we will also look under that as an alternate basename */ if (samplenames[0][0] == '*') skipfirst = 1; /* count the samples */ for (i = 0; samplenames[i+skipfirst] != 0; i++) ; if (i == 0) return NULL; /* allocate the array */ samples = auto_malloc(sizeof(struct loaded_samples) + (i-1) * sizeof(struct loaded_sample)); memset(samples, 0, sizeof(struct loaded_samples) + (i-1) * sizeof(struct loaded_sample)); samples->total = i; /* load the samples */ for (i = 0; i < samples->total; i++) if (samplenames[i+skipfirst][0]) { file_error filerr; mame_file *f; astring *fname; fname = astring_assemble_3(astring_alloc(), basename, PATH_SEPARATOR, samplenames[i+skipfirst]); filerr = mame_fopen(SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ, &f); if (filerr != FILERR_NONE && skipfirst) { astring_assemble_3(fname, samplenames[0] + 1, PATH_SEPARATOR, samplenames[i+skipfirst]); filerr = mame_fopen(SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ, &f); } if (filerr == FILERR_NONE) { read_wav_sample(f, &samples->sample[i]); mame_fclose(f); } astring_free(fname); } return samples; }
static void image_options_extract(running_machine *machine) { /* only extract the device options if we've added them */ if (options_get_bool(machine->options(), OPTION_ADDED_DEVICE_OPTIONS)) { int index = 0; device_image_interface *image = NULL; for (bool gotone = machine->m_devicelist.first(image); gotone; gotone = image->next(image)) { const char *filename = image->filename(); /* and set the option */ options_set_string(machine->options(), image->image_config().instance_name() , filename ? filename : "", OPTION_PRIORITY_CMDLINE); index++; } } /* write the config, if appropriate */ if (options_get_bool(machine->options(), OPTION_WRITECONFIG)) write_config(NULL, machine->gamedrv); }
void winsound_init(running_machine *machine) { // if no sound, don't create anything if (!options_get_bool(machine->options(), OPTION_SOUND)) return; // ensure we get called on the way out machine->add_notifier(MACHINE_NOTIFY_EXIT, sound_exit); // attempt to initialize directsound // don't make it fatal if we can't -- we'll just run without sound dsound_init(machine); }
static void image_driver_name_callback(core_options *opts, const char *arg) { const game_driver *driver; /* only add these options if we have not yet added them */ if (!options_get_bool(opts, OPTION_ADDED_DEVICE_OPTIONS)) { driver = driver_get_name(arg); if (driver != NULL) { image_add_device_options(opts, driver); } } }
void utf8_init () { #ifdef HAVE_NL_LANGINFO_CODESET #ifdef HAVE_NL_LANGINFO terminal_charset = xstrdup (nl_langinfo(CODESET)); assert (terminal_charset != NULL); if (!strcmp(terminal_charset, "UTF-8")) { #ifdef HAVE_NCURSESW logit ("Using UTF8 output"); using_utf8 = 1; #else /* HAVE_NCURSESW */ terminal_charset = xstrdup ("US-ASCII"); logit ("Using US-ASCII conversion - compiled without libncursesw"); #endif /* HAVE_NCURSESW */ } else logit ("Terminal character set: %s", terminal_charset); #else /* HAVE_NL_LANGINFO */ terminal_charset = xstrdup ("US-ASCII"); logit ("Assuming US-ASCII terminal character set"); #endif /* HAVE_NL_LANGINFO */ #endif /* HAVE_NL_LANGINFO_CODESET */ if (!using_utf8 && terminal_charset) { iconv_desc = iconv_open (terminal_charset, "UTF-8"); if (iconv_desc == (iconv_t)(-1)) log_errno ("iconv_open() failed", errno); } if (options_get_bool ("FileNamesIconv")) files_iconv_desc = iconv_open ("UTF-8", ""); if (options_get_bool ("NonUTFXterm")) xterm_iconv_desc = iconv_open ("", "UTF-8"); }
/** Initialize the logging drivers and options. */ static void kd_init_logging() { int i; int is_filtered; char buf[256]; char *ce, *channel, *last; const char *log_chan_enabled; const char *log_driver; const char log_driver_fmt[] = "log_%s.driver"; const char log_filtered_fmt[] = "log_%s.filter"; /* Order matters here. This is the order of the LOG_* constants found in /usr/include/sys/syslog.h. */ const char *log_levels[] = {"emergency", "alert", "critical", "error", "warning", "notice", "info", "debug", NULL}; /* Configure the basic log levels. */ for (i = 0; log_levels[i] != NULL; i++) { /* Read the log driver. If none was provided, we use the null driver. */ sprintf(buf, log_driver_fmt, log_levels[i]); log_driver = options_get_str(buf); /* Check if the level needs to be filtered. If the value was not provided we default to no. */ sprintf(buf, log_filtered_fmt, log_levels[i]); is_filtered = options_get_bool(buf); log_set_level(i, log_driver, is_filtered); } /* Configure the enabled channels. */ log_chan_enabled = options_get_str("log_channel.enabled"); if (strcmp(log_chan_enabled, "") == 0) return; ce = strdup(log_chan_enabled); for (channel = apr_strtok(ce, " ", &last); channel != NULL; channel = apr_strtok(NULL, " ", &last)) log_enable_channel(channel); free(ce); }
static int options_get(lua_State * L) { name k = to_name_ext(L, 2); auto it = get_option_declarations().find(k); if (it == get_option_declarations().end()) { throw exception(sstream() << "unknown option '" << k.to_string().c_str() << "'"); } else { option_declaration const & d = it->second; switch (d.kind()) { case BoolOption: return options_get_bool(L); case IntOption: return options_get_int(L); case UnsignedOption: return options_get_unsigned(L); case DoubleOption: return options_get_double(L); case StringOption: return options_get_string(L); default: throw exception(sstream() << "unsupported option kind for '" << k.to_string().c_str() << "'"); } } }
/* Find a preference entry matching the given filename extension and/or * MIME media type, or NULL. */ static decoder_t_preference *lookup_preference (const char *extn, const char *file, char **mime) { char *type, *subtype; decoder_t_preference *result; assert ((extn && extn[0]) || (file && file[0]) || (mime && *mime && *mime[0])); type = NULL; subtype = NULL; for (result = preferences; result; result = result->next) { if (!result->subtype) { if (extn && !strcasecmp (result->type, extn)) break; } else { if (!type) { if (mime && *mime == NULL && file && file[0]) { if (options_get_bool ("UseMimeMagic")) *mime = file_mime_type (file); } if (mime && *mime && strchr (*mime, '/')) type = xstrdup (*mime); if (type) { subtype = strchr (type, '/'); *subtype++ = 0x00; subtype = clean_mime_subtype (subtype); } } if (type) { if (!strcasecmp (result->type, type) && !strcasecmp (result->subtype, subtype)) break; } } } free (type); return result; }
void sound_init(running_machine *machine) { sound_private *global; const char *filename; machine->sound_data = global = auto_alloc_clear(machine, sound_private); /* handle -nosound */ global->nosound_mode = !options_get_bool(machine->options(), OPTION_SOUND); if (global->nosound_mode) machine->sample_rate = 11025; /* count the speakers */ VPRINTF(("total speakers = %d\n", speaker_output_count(machine->config))); /* allocate memory for mix buffers */ global->leftmix = auto_alloc_array(machine, INT32, machine->sample_rate); global->rightmix = auto_alloc_array(machine, INT32, machine->sample_rate); global->finalmix = auto_alloc_array(machine, INT16, machine->sample_rate); /* allocate a global timer for sound timing */ global->update_timer = timer_alloc(machine, sound_update, NULL); timer_adjust_periodic(global->update_timer, STREAMS_UPDATE_ATTOTIME, 0, STREAMS_UPDATE_ATTOTIME); /* finally, do all the routing */ VPRINTF(("route_sound\n")); route_sound(machine); /* open the output WAV file if specified */ filename = options_get_string(machine->options(), OPTION_WAVWRITE); if (filename[0] != 0) global->wavfile = wav_open(filename, machine->sample_rate, 2); /* enable sound by default */ global->enabled = TRUE; global->muted = FALSE; sound_set_attenuation(machine, options_get_int(machine->options(), OPTION_VOLUME)); /* register callbacks */ config_register(machine, "mixer", sound_load, sound_save); machine->add_notifier(MACHINE_NOTIFY_PAUSE, sound_pause); machine->add_notifier(MACHINE_NOTIFY_RESUME, sound_resume); machine->add_notifier(MACHINE_NOTIFY_RESET, sound_reset); machine->add_notifier(MACHINE_NOTIFY_EXIT, sound_exit); }
/* Set file title of an item. */ void plist_set_title_file (struct plist *plist, const int num, const char *title) { assert (LIMIT(num, plist->num)); if (plist->items[num].title_file) free (plist->items[num].title_file); #ifdef HAVE_RCC if (options_get_bool ("UseRCCForFilesystem")) { char *t_str = xstrdup (title); plist->items[num].title_file = rcc_reencode (t_str); return; } #endif plist->items[num].title_file = xstrdup (title); }
void running_machine::schedule_exit() { // if we are in-game but we started with the select game menu, return to that instead if (m_exit_to_game_select && options_get_string(&m_options, OPTION_GAMENAME)[0] != 0) { options_set_string(&m_options, OPTION_GAMENAME, "", OPTION_PRIORITY_CMDLINE); ui_menu_force_game_select(this, render_container_get_ui()); } // otherwise, exit for real else m_exit_pending = true; // if we're executing, abort out immediately m_scheduler.eat_all_cycles(); // if we're autosaving on exit, schedule a save as well if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE)) schedule_save("auto"); }
/* The playlist may have deleted items. */ int plist_load (struct plist *plist, const char *fname, const char *cwd, const int load_serial) { int num, read_tags; const char *ext; read_tags = options_get_bool ("ReadTags"); ext = ext_pos (fname); if (ext && !strcasecmp(ext, "pls")) num = plist_load_pls (plist, fname, cwd); else num = plist_load_m3u (plist, fname, cwd, load_serial); if (read_tags) switch_titles_tags (plist); else switch_titles_file (plist); return num; }
int kddb_open(apr_pool_t *pool, enum kddb_auth_mode auth_mode) { kdsql *main_conn; int err = -1; kdsql_init(pool); db = apr_pcalloc(pool, sizeof(kddb)); do { main_conn = kddb_connect_db(pool, auth_mode); if (!main_conn) break; db->login_db = kddblogin_new(pool, main_conn); if (!db->login_db) break; db->user_db = kddbuser_new(pool, main_conn, 0, 0); if (!db->user_db) break; db->skey_db = kddbskey_new(pool, main_conn); if (!db->skey_db) break; db->pkey_db = kddbpkey_new(pool, main_conn); if (!db->pkey_db) break; db->event_db = kddbevent_new(pool, main_conn); if (!db->event_db) break; db->otut_db = kddbotut_new(pool, main_conn); if (!db->otut_db) break; db->use_ldap = options_get_bool("ldap.enabled"); if (db->use_ldap) { if ((db->ldap_db = kdldap_new(pool)) == NULL) { KERROR_PUSH(_db_, 0, "cannot connect to LDAP server"); break; } } err = 0; } while (0); return err; }
/* Send requested option value to the client. Return 1 if OK. */ static int send_option (struct client *cli) { char *name; if (!(name = get_str(cli->socket))) return 0; /* We can send only a few options, others make no sense here. */ if (!valid_sync_option(name)) { logit ("Client wanted to get invalid option '%s'", name); free (name); return 0; } /* All supported options are boolean type. */ if (!send_data_bool(cli, options_get_bool(name))) { free (name); return 0; } free (name); return 1; }
running_machine::running_machine(const game_driver &driver, const machine_config &_config, core_options &options, bool exit_to_game_select) : m_regionlist(m_respool), m_devicelist(m_respool), config(&_config), m_config(_config), firstcpu(NULL), gamedrv(&driver), m_game(driver), primary_screen(NULL), palette(NULL), pens(NULL), colortable(NULL), shadow_table(NULL), priority_bitmap(NULL), sample_rate(options_get_int(&options, OPTION_SAMPLERATE)), debug_flags(0), ui_active(false), mame_data(NULL), timer_data(NULL), state_data(NULL), memory_data(NULL), palette_data(NULL), tilemap_data(NULL), streams_data(NULL), devices_data(NULL), romload_data(NULL), sound_data(NULL), input_data(NULL), input_port_data(NULL), ui_input_data(NULL), cheat_data(NULL), debugcpu_data(NULL), generic_machine_data(NULL), generic_video_data(NULL), generic_audio_data(NULL), m_debug_view(NULL), driver_data(NULL), m_logerror_list(NULL), m_scheduler(*this), m_options(options), m_basename(driver.name), m_current_phase(MACHINE_PHASE_PREINIT), m_paused(false), m_hard_reset_pending(false), m_exit_pending(false), m_exit_to_game_select(exit_to_game_select), m_new_driver_pending(NULL), m_soft_reset_timer(NULL), m_saveload_schedule(SLS_NONE), m_saveload_schedule_time(attotime_zero), m_saveload_searchpath(NULL), m_rand_seed(0x9d14abd7) { memset(gfx, 0, sizeof(gfx)); memset(&generic, 0, sizeof(generic)); memset(m_notifier_list, 0, sizeof(m_notifier_list)); memset(&m_base_time, 0, sizeof(m_base_time)); /* attach this machine to all the devices in the configuration */ m_devicelist.import_config_list(m_config.m_devicelist, *this); /* allocate the driver data (after devices) */ if (m_config.m_driver_data_alloc != NULL) driver_data = (*m_config.m_driver_data_alloc)(*this); /* find devices */ primary_screen = screen_first(*this); for (device_t *device = m_devicelist.first(); device != NULL; device = device->next()) if (dynamic_cast<cpu_device *>(device) != NULL) { firstcpu = downcast<cpu_device *>(device); break; } cpu[0] = firstcpu; for (cpunum = 1; cpunum < ARRAY_LENGTH(cpu) && cpu[cpunum - 1] != NULL; cpunum++) cpu[cpunum] = cpu[cpunum - 1]->typenext(); /* fetch core options */ if (options_get_bool(&m_options, OPTION_DEBUG)) debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (options_get_bool(&m_options, OPTION_DEBUG_INTERNAL) ? 0 : DEBUG_FLAG_OSD_ENABLED); }
int winwindow_video_window_create(int index, win_monitor_info *monitor, const win_window_config *config) { win_window_info *window, *win; char option[20]; assert(GetCurrentThreadId() == main_threadid); // allocate a new window object window = malloc_or_die(sizeof(*window)); memset(window, 0, sizeof(*window)); window->maxwidth = config->width; window->maxheight = config->height; window->refresh = config->refresh; window->monitor = monitor; window->fullscreen = !video_config.windowed; // see if we are safe for fullscreen window->fullscreen_safe = TRUE; for (win = win_window_list; win != NULL; win = win->next) if (win->monitor == monitor) window->fullscreen_safe = FALSE; // add us to the list *last_window_ptr = window; last_window_ptr = &window->next; // create a lock that we can use to skip blitting window->render_lock = osd_lock_alloc(); // load the layout window->target = render_target_alloc(NULL, 0); if (window->target == NULL) goto error; render_target_set_orientation(window->target, video_orientation); render_target_set_layer_config(window->target, video_config.layerconfig); // set the specific view sprintf(option, "view%d", index); set_starting_view(index, window, options_get_string(option)); // remember the current values in case they change window->targetview = render_target_get_view(window->target); window->targetorient = render_target_get_orientation(window->target); window->targetlayerconfig = render_target_get_layer_config(window->target); // make the window title if (video_config.numscreens == 1) sprintf(window->title, APPNAME ": %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); else sprintf(window->title, APPNAME ": %s [%s] - Screen %d", Machine->gamedrv->description, Machine->gamedrv->name, index); // set the initial maximized state window->startmaximized = options_get_bool("maximize"); // finish the window creation on the window thread if (multithreading_enabled) { // wait until the window thread is ready to respond to events WaitForSingleObject(window_thread_ready_event, INFINITE); PostThreadMessage(window_threadid, WM_USER_FINISH_CREATE_WINDOW, 0, (LPARAM)window); while (window->init_state == 0) Sleep(1); } else window->init_state = complete_create(window) ? -1 : 1; // handle error conditions if (window->init_state == -1) goto error; return 0; error: winwindow_video_window_destroy(window); return 1; }
int winwindow_init(running_machine *machine) { size_t temp; // determine if we are using multithreading or not multithreading_enabled = options_get_bool("multithreading"); // get the main thread ID before anything else main_threadid = GetCurrentThreadId(); // ensure we get called on the way out add_exit_callback(machine, winwindow_exit); // set up window class and register it if (create_window_class()) return 1; // create an event to signal UI pausing ui_pause_event = CreateEvent(NULL, TRUE, FALSE, NULL); if (!ui_pause_event) return 1; // if multithreading, create a thread to run the windows if (multithreading_enabled) { // create an event to signal when the window thread is ready window_thread_ready_event = CreateEvent(NULL, TRUE, FALSE, NULL); if (!window_thread_ready_event) return 1; // create a thread to run the windows from temp = _beginthreadex(NULL, 0, thread_entry, NULL, 0, (unsigned *)&window_threadid); window_thread = (HANDLE)temp; if (window_thread == NULL) return 1; // set the thread priority equal to the main MAME thread SetThreadPriority(window_thread, GetThreadPriority(GetCurrentThread())); } // otherwise, treat the window thread as the main thread else { window_thread = GetCurrentThread(); window_threadid = main_threadid; } // initialize the drawers if (video_config.mode == VIDEO_MODE_D3D) { if (drawd3d_init(&draw)) video_config.mode = VIDEO_MODE_GDI; } if (video_config.mode == VIDEO_MODE_DDRAW) { if (drawdd_init(&draw)) video_config.mode = VIDEO_MODE_GDI; } if (video_config.mode == VIDEO_MODE_GDI) { if (drawgdi_init(&draw)) return 1; } if (video_config.mode == VIDEO_MODE_NONE) { if (drawnone_init(&draw)) return 1; } // set up the window list last_window_ptr = &win_window_list; return 0; }