static void hiscore_load (running_machine &machine) { file_error filerr; emu_file f(machine.options().hiscore_directory(), OPEN_FLAG_READ); filerr = f.open(machine.basename(), ".hi"); state.hiscores_have_been_loaded = 1; if (filerr == FILERR_NONE) { memory_range *mem_range = state.mem_range; while (mem_range) { UINT8 *data = global_alloc_array(UINT8, mem_range->num_bytes); if (data) { /* this buffer will almost certainly be small enough to be dynamically allocated, but let's avoid memory trashing just in case */ f.read(data, mem_range->num_bytes); copy_to_memory (machine,mem_range->cpu, mem_range->addr, data, mem_range->num_bytes); global_free_array(data); } mem_range = mem_range->next; } f.close(); } }
void memcard_eject(running_machine &machine) { generic_machine_private *state = machine.generic_machine_data; char name[16]; /* if no card is preset, just ignore */ if (state->memcard_inserted == -1) return; /* create a name */ memcard_name(state->memcard_inserted, name); /* open the file; if we can't, it's an error */ emu_file file(machine.options().memcard_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); file_error filerr = file.open(machine.basename(), PATH_SEPARATOR, name); if (filerr != FILERR_NONE) return; /* initialize and then load the card */ if (machine.config().m_memcard_handler) (*machine.config().m_memcard_handler)(machine, file, MEMCARD_EJECT); /* close the file */ state->memcard_inserted = -1; }
int draw13_init(running_machine &machine, sdl_draw_info *callbacks) { const char *stemp; // fill in the callbacks callbacks->exit = draw13_exit; callbacks->attach = draw13_attach; mame_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n"); expand_copy_info(blit_info_default); //FIXME: -opengl16 should be -opengl -prefer16bpp //if (video_config.prefer16bpp_tex) expand_copy_info(blit_info_16bpp); // Load the GL library now - else MT will fail stemp = downcast<sdl_options &>(machine.options()).gl_lib(); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0) stemp = NULL; // No fatalerror here since not all video drivers support GL ! if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==NULL mame_printf_verbose("Warning: Unable to load opengl library: %s\n", stemp ? stemp : "<default>"); else mame_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); return 0; }
cheat_manager::cheat_manager(running_machine &machine) : m_machine(machine), m_disabled(true), m_symtable(&machine) { // if the cheat engine is disabled, we're done if (!machine.options().cheat()) return; m_output.resize(UI_TARGET_FONT_ROWS*2); m_justify.resize(UI_TARGET_FONT_ROWS*2); // request a callback machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(cheat_manager::frame_update), this)); // create a global symbol table m_symtable.add("frame", symbol_table::READ_ONLY, &m_framecount); m_symtable.add("frombcd", nullptr, 1, 1, execute_frombcd); m_symtable.add("tobcd", nullptr, 1, 1, execute_tobcd); // we rely on the debugger expression callbacks; if the debugger isn't // enabled, we must jumpstart them manually if ((machine.debug_flags & DEBUG_FLAG_ENABLED) == 0) { m_cpu = std::make_unique<debugger_cpu>(machine); // configure for memory access (shared with debugger) m_cpu->configure_memory(m_symtable); } // load the cheats reload(); }
int memcard_insert(running_machine &machine, int index) { generic_machine_private *state = machine.generic_machine_data; char name[16]; /* if a card is already inserted, eject it first */ if (state->memcard_inserted != -1) memcard_eject(machine); assert(state->memcard_inserted == -1); /* create a name */ memcard_name(index, name); /* open the file; if we can't, it's an error */ emu_file file(machine.options().memcard_directory(), OPEN_FLAG_READ); file_error filerr = file.open(machine.basename(), PATH_SEPARATOR, name); if (filerr != FILERR_NONE) return 1; /* initialize and then load the card */ if (machine.config().m_memcard_handler) (*machine.config().m_memcard_handler)(machine, file, MEMCARD_INSERT); /* close the file */ state->memcard_inserted = index; return 0; }
void winvideo_init(running_machine &machine) { int index; // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(winvideo_exit), &machine)); // extract data from the options extract_video_config(machine); // set up monitors first init_monitors(); // initialize the window system so we can make windows winwindow_init(machine); // create the windows windows_options &options = downcast<windows_options &>(machine.options()); for (index = 0; index < video_config.numscreens; index++) winwindow_video_window_create(machine, index, pick_monitor(options, index), &video_config.window[index]); if (video_config.mode != VIDEO_MODE_NONE) SetForegroundWindow(win_window_list->hwnd); // possibly create the debug window, but don't show it yet if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) debugwin_init_windows(machine); }
cheat_manager::cheat_manager(running_machine &machine) : m_machine(machine), m_cheatlist(machine.respool()), m_disabled(true), m_symtable(&machine) { // if the cheat engine is disabled, we're done if (!machine.options().cheat()) return; // request a callback machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(cheat_manager::frame_update), this)); // create a global symbol table m_symtable.add("frame", symbol_table::READ_ONLY, &m_framecount); m_symtable.add("frombcd", NULL, 1, 1, execute_frombcd); m_symtable.add("tobcd", NULL, 1, 1, execute_tobcd); // we rely on the debugger expression callbacks; if the debugger isn't // enabled, we must jumpstart them manually if ((machine.debug_flags & DEBUG_FLAG_ENABLED) == 0) debug_cpu_init(machine); // configure for memory access (shared with debugger) debug_cpu_configure_memory(machine, m_symtable); // load the cheats reload(); }
ui_menu_misc_options::ui_menu_misc_options(running_machine &machine, render_container *container) : ui_menu(machine, container) { for (int d = 1; d < ARRAY_LENGTH(m_options); ++d) if (machine.ui().options().exists(m_options[d].option)) m_options[d].status = machine.ui().options().bool_value(m_options[d].option); else m_options[d].status = machine.options().bool_value(m_options[d].option); }
void winsound_init(running_machine &machine) { // if no sound, don't create anything if (!machine.options().sound()) return; #ifdef USE_AUDIO_SYNC audio_sync = machine.options().bool_value(WINOPTION_AUDIO_SYNC); #endif /* USE_AUDIO_SYNC */ // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sound_exit), &machine)); // attempt to initialize directsound // don't make it fatal if we can't -- we'll just run without sound dsound_init(machine); }
ui_menu_sound_options::ui_menu_sound_options(running_machine &machine, render_container *container) : ui_menu(machine, container) { osd_options &options = downcast<osd_options &>(machine.options()); m_sample_rate = machine.options().sample_rate(); m_sound = (strcmp(options.sound(), OSDOPTVAL_NONE) && strcmp(options.sound(), "0")); m_samples = machine.options().samples(); int total = ARRAY_LENGTH(m_sound_rate); for (m_cur_rates = 0; m_cur_rates < total; m_cur_rates++) if (m_sample_rate == m_sound_rate[m_cur_rates]) break; if (m_cur_rates == total) m_cur_rates = 2; }
int config_load_settings(running_machine &machine) { const char *controller = machine.options().ctrlr(); config_type *type; int loaded = 0; /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) type->load(CONFIG_TYPE_INIT, NULL); /* now load the controller file */ if (controller[0] != 0) { /* open the config file */ emu_file file(machine.options().ctrlr_path(), OPEN_FLAG_READ); file_error filerr = file.open(controller, ".cfg"); if (filerr != FILERR_NONE) throw emu_fatalerror(_("Could not load controller file %s.cfg"), controller); /* load the XML */ if (!config_load_xml(machine, file, CONFIG_TYPE_CONTROLLER)) throw emu_fatalerror(_("Could not load controller file %s.cfg"), controller); } /* next load the defaults file */ emu_file file(machine.options().cfg_directory(), OPEN_FLAG_READ); file_error filerr = file.open("default.cfg"); if (filerr == FILERR_NONE) config_load_xml(machine, file, CONFIG_TYPE_DEFAULT); /* finally, load the game-specific file */ filerr = file.open(machine.basename(), ".cfg"); if (filerr == FILERR_NONE) loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME); /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) type->load(CONFIG_TYPE_FINAL, NULL); /* if we didn't find a saved config, return 0 so the main core knows that it */ /* is the first time the game is run and it should diplay the disclaimer. */ return loaded; }
static void extract_video_config(running_machine &machine) { windows_options &options = downcast<windows_options &>(machine.options()); const char *stemp; // global options: extract the data video_config.windowed = options.window(); video_config.prescale = options.prescale(); video_config.keepaspect = options.keep_aspect(); video_config.numscreens = options.numscreens(); // if we are in debug mode, never go full screen if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) video_config.windowed = TRUE; // per-window options: extract the data const char *default_resolution = options.resolution(); get_resolution(default_resolution, options.resolution(0), &video_config.window[0], TRUE); get_resolution(default_resolution, options.resolution(1), &video_config.window[1], TRUE); get_resolution(default_resolution, options.resolution(2), &video_config.window[2], TRUE); get_resolution(default_resolution, options.resolution(3), &video_config.window[3], TRUE); // video options: extract the data stemp = options.video(); if (strcmp(stemp, "d3d") == 0) video_config.mode = VIDEO_MODE_D3D; else if (strcmp(stemp, "auto") == 0) video_config.mode = VIDEO_MODE_D3D; else if (strcmp(stemp, "ddraw") == 0) video_config.mode = VIDEO_MODE_DDRAW; else if (strcmp(stemp, "gdi") == 0) video_config.mode = VIDEO_MODE_GDI; else if (strcmp(stemp, "none") == 0) { video_config.mode = VIDEO_MODE_NONE; if (options.seconds_to_run() == 0) osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n"); } else { osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp); video_config.mode = VIDEO_MODE_GDI; } video_config.waitvsync = options.wait_vsync(); video_config.syncrefresh = options.sync_refresh(); video_config.triplebuf = options.triple_buffer(); video_config.switchres = options.switch_res(); // ddraw options: extract the data video_config.hwstretch = options.hwstretch(); // d3d options: extract the data video_config.filter = options.filter(); if (video_config.prescale == 0) video_config.prescale = 1; }
void emulator_info::display_ui_chooser(running_machine& machine) { // force the UI to show the game select screen if (strcmp(machine.options().ui(), "simple") == 0) { ui_simple_menu_select_game::force_game_select(machine, &machine.render().ui_container()); } else { ui_menu_select_game::force_game_select(machine, &machine.render().ui_container()); } }
void emulator_info::display_ui_chooser(running_machine& machine) { // force the UI to show the game select screen mame_ui_manager &mui = mame_machine_manager::instance()->ui(); render_container &container = machine.render().ui_container(); if (machine.options().ui() == emu_options::UI_SIMPLE) ui::simple_menu_select_game::force_game_select(mui, container); else ui::menu_select_game::force_game_select(mui, container); }
ui_menu_custom_ui::ui_menu_custom_ui(running_machine &machine, render_container *container) : ui_menu(machine, container) { // load languages file_enumerator path(machine.options().language_path()); const char *lang = machine.options().language(); const osd_directory_entry *dirent; int cnt = 0; while ((dirent = path.next()) != nullptr) if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0 && strcmp(dirent->name, "..") != 0) { auto name = std::string(dirent->name); int i = strreplace(name, "_", " ("); if (i > 0) name = name.append(")"); m_lang.push_back(name); if (strcmp(name.c_str(), lang) == 0) m_currlang = cnt; ++cnt; } }
static void create_bitmap(running_machine &machine, int player) { int x, y; char filename[20]; rgb_t color = crosshair_colors[player]; /* if we have a bitmap and texture for this player, kill it */ if (global.bitmap[player] == NULL) global.bitmap[player] = global_alloc(bitmap_argb32); machine.render().texture_free(global.texture[player]); emu_file crossfile(machine.options().crosshair_path(), OPEN_FLAG_READ); if (global.name[player][0] != 0) { /* look for user specified file */ sprintf(filename, "%s.png", global.name[player]); render_load_png(*global.bitmap[player], crossfile, NULL, filename); } else { /* look for default cross?.png in crsshair\game dir */ sprintf(filename, "cross%d.png", player + 1); render_load_png(*global.bitmap[player], crossfile, machine.system().name, filename); /* look for default cross?.png in crsshair dir */ if (!global.bitmap[player]->valid()) render_load_png(*global.bitmap[player], crossfile, NULL, filename); } /* if that didn't work, use the built-in one */ if (!global.bitmap[player]->valid()) { /* allocate a blank bitmap to start with */ global.bitmap[player]->allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE); global.bitmap[player]->fill(MAKE_ARGB(0x00,0xff,0xff,0xff)); /* extract the raw source data to it */ for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++) { /* assume it is mirrored vertically */ UINT32 *dest0 = &global.bitmap[player]->pix32(y); UINT32 *dest1 = &global.bitmap[player]->pix32(CROSSHAIR_RAW_SIZE - 1 - y); /* extract to two rows simultaneously */ for (x = 0; x < CROSSHAIR_RAW_SIZE; x++) if ((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80) dest0[x] = dest1[x] = MAKE_ARGB(0xff,0x00,0x00,0x00) | color; } } /* create a texture to reference the bitmap */ global.texture[player] = machine.render().texture_alloc(render_texture::hq_scale); global.texture[player]->set_bitmap(*global.bitmap[player], global.bitmap[player]->cliprect(), TEXFORMAT_ARGB32); }
int sdlwindow_init(running_machine &machine) { mame_printf_verbose("Enter sdlwindow_init\n"); // determine if we are using multithreading or not multithreading_enabled = downcast<sdl_options &>(machine.options()).multithreading(); // get the main thread ID before anything else main_threadid = SDL_ThreadID(); // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdlwindow_exit), &machine)); // if multithreading, create a thread to run the windows if (multithreading_enabled) { // create a thread to run the windows from work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); 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(machine, &draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif #if SDLMAME_SDL2 if (video_config.mode == VIDEO_MODE_SDL13) { if (draw13_init(machine, &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; mame_printf_verbose("Leave sdlwindow_init\n"); return 0; }
win32_lightgun_device(running_machine& machine, const char *name, input_module &module) : event_based_device(machine, name, DEVICE_CLASS_LIGHTGUN, module), m_lightgun_shared_axis_mode(FALSE), m_gun_index(0), mouse({0}) { m_lightgun_shared_axis_mode = downcast<windows_options &>(machine.options()).dual_lightgun(); // Since we are about to be added to the list, the current size is the zero-based index of where we will be m_gun_index = downcast<wininput_module&>(module).devicelist()->size(); }
ui_menu_remove_folder::ui_menu_remove_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container) { m_ref = ref - 1; if (machine.ui().options().exists(s_folders_entry[m_ref].option)) { m_searchpath.assign(machine.ui().options().value(s_folders_entry[m_ref].option)); } else { m_searchpath.assign(machine.options().value(s_folders_entry[m_ref].option)); } }
void input_init(running_machine &machine) override { // get the number of devices, allocate a device list, and fetch it int device_count = 0; if (get_rawinput_device_list(NULL, &device_count, sizeof(RAWINPUTDEVICELIST)) != 0) return; if (device_count == 0) return; auto rawinput_devices = std::make_unique<RAWINPUTDEVICELIST[]>(device_count); if (get_rawinput_device_list(rawinput_devices.get(), &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) return; // iterate backwards through devices; new devices are added at the head for (int devnum = device_count - 1; devnum >= 0; devnum--) { RAWINPUTDEVICELIST *device = &rawinput_devices[devnum]; add_rawinput_device(machine, device); } // don't enable global inputs when debugging if (!machine.options().debug()) { m_global_inputs_enabled = downcast<windows_options &>(machine.options()).global_inputs(); } // If we added no devices, no need to register for notifications if (devicelist()->size() == 0) return; // finally, register to receive raw input WM_INPUT messages if we found devices RAWINPUTDEVICE registration; registration.usUsagePage = usagepage(); registration.usUsage = usage(); registration.dwFlags = m_global_inputs_enabled ? 0x00000100 : 0; registration.hwndTarget = win_window_list->m_hwnd; // register the device register_rawinput_devices(®istration, 1, sizeof(registration)); }
void osd_common_t::init(running_machine &machine) { // // This function is responsible for initializing the OSD-specific // video and input functionality, and registering that functionality // with the MAME core. // // In terms of video, this function is expected to create one or more // render_targets that will be used by the MAME core to provide graphics // data to the system. Although it is possible to do this later, the // assumption in the MAME core is that the user interface will be // visible starting at init() time, so you will have some work to // do to avoid these assumptions. // // In terms of input, this function is expected to enumerate all input // devices available and describe them to the MAME core by adding // input devices and their attached items (buttons/axes) via the input // system. // // Beyond these core responsibilities, init() should also initialize // any other OSD systems that require information about the current // running_machine. // // This callback is also the last opportunity to adjust the options // before they are consumed by the rest of the core. // // Future work/changes: // // Audio initialization may eventually move into here as well, // instead of relying on independent callbacks from each system. // m_machine = &machine; osd_options &options = downcast<osd_options &>(machine.options()); // extract the verbose printing option if (options.verbose()) set_verbose(true); // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this)); /* now setup watchdog */ int watchdog_timeout = options.watchdog(); if (watchdog_timeout != 0) { m_watchdog = std::make_unique<osd_watchdog>(); m_watchdog->setTimeout(watchdog_timeout); } }
void image_device_init(running_machine &machine) { const char *image_name; /* make sure that any required devices have been allocated */ image_interface_iterator iter(machine.root_device()); for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) { /* is an image specified for this image */ image_name = machine.options().device_option(*image); if ((image_name != NULL) && (image_name[0] != '\0')) { /* mark init state */ image->set_init_phase(); /* try to load this image */ bool result = image->load(image_name); /* did the image load fail? */ if (result) { /* retrieve image error message */ astring image_err = astring(image->error()); astring image_basename(image_name); /* unload all images */ image_unload_all(machine); fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s", image->device().name(), image_basename.cstr(), image_err.cstr()); } } } for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) { /* is an image specified for this image */ image_name = image->filename(); if (!((image_name != NULL) && (image_name[0] != '\0'))) { /* no image... must this device be loaded? */ if (image->must_be_loaded()) { fatalerror_exitcode(machine, MAMERR_DEVICE, "Driver requires that device \"%s\" must have an image to load", image->instance_name()); } } } }
ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev, float _x0, float _y0) : ui_menu(machine, container) , m_drv(prev) , m_opts(machine.options()) , x0(_x0) , y0(_y0) , m_curbios(0) { // parse the INI file std::string error; mame_options::parse_standard_inis(m_opts,error, m_drv); setup_bios(); }
image_manager::image_manager(running_machine &machine) : m_machine(machine) { // make sure that any required devices have been allocated for (device_image_interface &image : image_interface_iterator(machine.root_device())) { // ignore things not user loadable if (!image.user_loadable()) continue; // is an image specified for this image const char *image_name_ptr = machine.options().value(image.instance_name()); if ((image_name_ptr != nullptr) && (image_name_ptr[0] != '\0')) { image_init_result result = image_init_result::FAIL; std::string image_name(image_name_ptr); // mark init state image.set_init_phase(); // try as a softlist if (software_name_parse(image_name)) result = image.load_software(image_name); // failing that, try as an image if (result != image_init_result::PASS) result = image.load(image_name); // failing that, try creating it (if appropriate) if (result != image_init_result::PASS && image.support_command_line_image_creation()) result = image.create(image_name); // did the image load fail? if (result != image_init_result::PASS) { // retrieve image error message std::string image_err = std::string(image.error()); // unload all images unload_all(); fatalerror_exitcode(machine, EMU_ERR_DEVICE, "Device %s load (%s) failed: %s", image.device().name(), image_name.c_str(), image_err.c_str()); } } } machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_manager::config_load), this), config_saveload_delegate(FUNC(image_manager::config_save), this)); }
void nvram_load(running_machine &machine) { if (machine.config().m_nvram_handler != NULL) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (file.open(nvram_filename(machine,filename),".nv") == FILERR_NONE) { (*machine.config().m_nvram_handler)(machine, &file, FALSE); file.close(); } else { (*machine.config().m_nvram_handler)(machine, NULL, FALSE); } } device_nvram_interface *nvram = NULL; if (machine.devicelist().first(nvram)) { for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram)) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (file.open(nvram_filename(nvram->device(),filename)) == FILERR_NONE) { nvram->nvram_load(file); file.close(); } else { nvram->nvram_reset(); } } } }
int sdlvideo_init(running_machine &machine) { int index, tc; // extract data from the options extract_video_config(machine); // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(video_exit), &machine)); // set up monitors first init_monitors(); // we need the beam width in a float, contrary to what the core does. video_config.beamwidth = machine.options().beam(); // initialize the window system so we can make windows if (sdlwindow_init(machine)) return 1; tc = machine.total_colors(); // create the windows sdl_options &options = downcast<sdl_options &>(machine.options()); for (index = 0; index < video_config.numscreens; index++) { sdl_window_config conf; memset(&conf, 0, sizeof(conf)); extract_window_config(machine, index, &conf); conf.totalColors = tc; if (sdlwindow_video_window_create(machine, index, pick_monitor(options, index), &conf)) return 1; } return 0; }
int nvram_size(running_machine &machine) { int retval=0; if (machine.config().m_nvram_handler != NULL) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (file.open(nvram_filename(filename, machine.root_device()),".nv") == FILERR_NONE) { retval += file.size(); } } nvram_interface_iterator iter(machine.root_device()); for (device_nvram_interface *nvram = iter.first(); nvram != NULL; nvram = iter.next()) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) { retval += file.size(); } } return retval; }
static void image_options_extract(running_machine &machine) { /* only extract the device options if we've added them no need to assert in case they are missing */ { int index = 0; device_image_interface *image = NULL; for (bool gotone = machine.devicelist().first(image); gotone; gotone = image->next(image)) { const char *filename = image->filename(); /* and set the option */ astring error; machine.options().set_value(image->instance_name(), filename ? filename : "", OPTION_PRIORITY_CMDLINE, error); index++; } } /* write the config, if appropriate */ if (machine.options().write_config()) write_config(machine.options(), NULL, &machine.system()); }
void nvram_save(running_machine &machine) { static bool first=true; if(netCommon) { if(nvram_size(machine)>=32*1024*1024) { if(first) { ui_popup_time(3, "The NVRAM for this game is too big, not saving NVRAM."); first = false; } return; } } if (machine.config().m_nvram_handler != NULL) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (file.open(nvram_filename(filename, machine.root_device()), ".nv") == FILERR_NONE) { (*machine.config().m_nvram_handler)(machine, &file, TRUE); file.close(); } } nvram_interface_iterator iter(machine.root_device()); for (device_nvram_interface *nvram = iter.first(); nvram != NULL; nvram = iter.next()) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) { nvram->nvram_save(file); file.close(); } } }
// FIXME: machine only used to access options. void renderer_sdl2::init(running_machine &machine) { osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n"); #if USE_OPENGL // Load the GL library now - else MT will fail const char *stemp = downcast<sdl_options &>(machine.options()).gl_lib(); #else const char *stemp = nullptr; #endif if (stemp != nullptr && strcmp(stemp, OSDOPTVAL_AUTO) == 0) stemp = nullptr; // No fatalerror here since not all video drivers support GL ! if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==nullptr osd_printf_warning("Warning: Unable to load opengl library: %s\n", stemp ? stemp : "<default>"); else osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); }