void timer_device::device_validity_check(validity_checker &valid) const { // type based configuration switch (m_type) { case TIMER_TYPE_GENERIC: if (m_screen_tag != NULL || m_first_vpos != 0 || m_start_delay != attotime::zero) mame_printf_warning("Generic timer specified parameters for a scanline timer\n"); if (m_period != attotime::zero || m_start_delay != attotime::zero) mame_printf_warning("Generic timer specified parameters for a periodic timer\n"); break; case TIMER_TYPE_PERIODIC: if (m_screen_tag != NULL || m_first_vpos != 0) mame_printf_warning("Periodic timer specified parameters for a scanline timer\n"); if (m_period <= attotime::zero) mame_printf_error("Periodic timer specified invalid period\n"); break; case TIMER_TYPE_SCANLINE: if (m_period != attotime::zero || m_start_delay != attotime::zero) mame_printf_warning("Scanline timer specified parameters for a periodic timer\n"); if (m_param != 0) mame_printf_warning("Scanline timer specified parameter which is ignored\n"); if (m_first_vpos < 0) mame_printf_error("Scanline timer specified invalid initial position\n"); if (m_increment < 0) mame_printf_error("Scanline timer specified invalid increment\n"); break; default: mame_printf_error("Invalid type specified\n"); break; } }
int device_valididtychecks(void) { int error = 0; int i; if ((sizeof(device_info_array) / sizeof(device_info_array[0])) != IO_COUNT) { mame_printf_error("device_info_array array should match size of IO_* enum\n"); error = 1; } /* Check the device struct array */ for (i = 0; i < sizeof(device_info_array) / sizeof(device_info_array[0]); i++) { if (device_info_array[i].type != i) { mame_printf_error("Device struct array order mismatch\n"); error = 1; break; } if (!device_info_array[i].name) { mame_printf_error("device_info_array[%d].name appears to be NULL\n", i); error = 1; } if (!device_info_array[i].shortname) { mame_printf_error("device_info_array[%d].shortname appears to be NULL\n", i); error = 1; } } return error; }
float options_get_float_range(const char *name, float minval, float maxval) { options_data *data = find_entry_data(name, FALSE); float value = 0; if (data == NULL) mame_printf_error("Unexpected float option %s queried\n", name); else if (data->data == NULL || sscanf(data->data, "%f", &value) != 1) { if (data->defdata != NULL) { options_set_string(name, data->defdata); value = options_get_float(name); } if (!data->error_reported) { mame_printf_error("Illegal float value for %s; reverting to %f\n", data->names[0], (double)value); data->error_reported = TRUE; } } else if (value < minval || value > maxval) { options_set_string(name, data->defdata); value = options_get_float(name); if (!data->error_reported) { mame_printf_error("Invalid %s value (must be between %f and %f); reverting to %f\n", data->names[0], (double)minval, (double)maxval, (double)value); data->error_reported = TRUE; } } return value; }
static int verify_length_and_hash(emu_file *file, const char *name, UINT32 explength, const hash_collection &hashes) { int retVal = 0; if (file==NULL) return 0; /* verify length */ UINT32 actlength = file->size(); if (explength != actlength) { mame_printf_error("%s WRONG LENGTH (expected: %d found: %d)\n", name, explength, actlength); retVal++; } /* If there is no good dump known, write it */ astring tempstr; hash_collection &acthashes = file->hashes(hashes.hash_types(tempstr)); if (hashes.flag(hash_collection::FLAG_NO_DUMP)) { mame_printf_error("%s NO GOOD DUMP KNOWN\n", name); } /* verify checksums */ else if (hashes != acthashes) { /* otherwise, it's just bad */ mame_printf_error("%s WRONG CHECKSUMS:\n", name); dump_wrong_and_correct_checksums(hashes, acthashes); retVal++; } /* If it matches, but it is actually a bad dump, write it */ else if (hashes.flag(hash_collection::FLAG_BAD_DUMP)) { mame_printf_error("%s NEEDS REDUMP\n",name); } return retVal; }
int options_get_int_range(const char *name, int minval, int maxval) { options_data *data = find_entry_data(name, FALSE); int value = 0; if (data == NULL) mame_printf_error("Unexpected integer option %s queried\n", name); else if (data->data == NULL || sscanf(data->data, "%d", &value) != 1) { if (data->defdata != NULL) { options_set_string(name, data->defdata); value = options_get_int(name); } if (!data->error_reported) { mame_printf_error("Illegal integer value for %s; reverting to %d\n", data->names[0], value); data->error_reported = TRUE; } } else if (value < minval || value > maxval) { options_set_string(name, data->defdata); value = options_get_int(name); if (!data->error_reported) { mame_printf_error("Invalid %s value (must be between %d and %d); reverting to %d\n", data->names[0], minval, maxval, value); data->error_reported = TRUE; } } return value; }
void device_video_interface::interface_validity_check(validity_checker &valid) const { // only look up screens if we haven't explicitly requested no screen screen_device *screen = NULL; if (m_screen_tag != NULL) { // find the screen device if explicitly configured if (strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { screen = device().siblingdevice<screen_device>(m_screen_tag); if (screen == NULL) mame_printf_error("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag()); } // otherwise, look for a single match else { screen_device_iterator iter(device().mconfig().root_device()); screen = iter.first(); if (iter.next() != NULL) mame_printf_error("No screen specified for device '%s', but multiple screens found", device().tag()); } } // error if no screen is found if (screen == NULL && m_screen_required) mame_printf_error("Device '%s' requires a screen", device().tag()); }
bool device_sound_interface::interface_validity_check(emu_options &options, const game_driver &driver) const { bool error = false; // loop over all the routes for (const sound_route *route = first_route(); route != NULL; route = route->next()) { // find a device with the requested tag const device_t *target = device().mconfig().devicelist().find(route->m_target); if (target == NULL) { mame_printf_error("%s: %s attempting to route sound to non-existant device '%s'\n", driver.source_file, driver.name, route->m_target); error = true; } // if it's not a speaker or a sound device, error const device_sound_interface *sound; if (target != NULL && target->type() != SPEAKER && !target->dev_interface(sound)) { mame_printf_error("%s: %s attempting to route sound to a non-sound device '%s' (%s)\n", driver.source_file, driver.name, route->m_target, target->name()); error = true; } } return error; }
void eeprom_base_device::device_validity_check(validity_checker &valid) const { // ensure the number of cells is an even power of 2 if (m_cells != (1 << m_address_bits)) mame_printf_error("Invalid EEPROM size %d specified\n", m_cells); // ensure only the sizes we support are requested if (m_data_bits != 8 && m_data_bits != 16) mame_printf_error("Invalid EEPROM data width %d specified\n", m_data_bits); }
int options_parse_command_line(int argc, char **argv) { int unadorned_index = 0; int arg; /* loop over commands, looking for options */ for (arg = 1; arg < argc; arg++) { options_data *data; const char *optionname; const char *newdata; /* determine the entry name to search for */ if (argv[arg][0] == '-') optionname = &argv[arg][1]; else { optionname = OPTION_UNADORNED(unadorned_index); unadorned_index++; } /* find our entry */ data = find_entry_data(optionname, TRUE); if (data == NULL) { mame_printf_error("Error: unknown option: %s\n", argv[arg]); return 1; } if ((data->flags & (OPTION_DEPRECATED | OPTION_INTERNAL)) != 0) continue; /* get the data for this argument, special casing booleans */ if ((data->flags & (OPTION_BOOLEAN | OPTION_COMMAND)) != 0) newdata = (strncmp(&argv[arg][1], "no", 2) == 0) ? "0" : "1"; else if (argv[arg][0] != '-') newdata = argv[arg]; else if (arg + 1 < argc) newdata = argv[++arg]; else { mame_printf_error("Error: option %s expected a parameter\n", argv[arg]); return 1; } /* invoke callback, if present */ if (data->callback != NULL) (*data->callback)(newdata); /* allocate a new copy of data for this */ update_data(data, newdata); } return 0; }
bool timer_device_config::device_validity_check(const game_driver &driver) const { bool error = false; // type based configuration switch (m_type) { case TIMER_TYPE_GENERIC: if (m_screen != NULL || m_first_vpos != 0 || m_start_delay != 0) mame_printf_warning("%s: %s generic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); if (m_period != 0 || m_start_delay != 0) mame_printf_warning("%s: %s generic timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); break; case TIMER_TYPE_PERIODIC: if (m_screen != NULL || m_first_vpos != 0) mame_printf_warning("%s: %s periodic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); if (m_period <= 0) { mame_printf_error("%s: %s periodic timer '%s' specified invalid period\n", driver.source_file, driver.name, tag()); error = true; } break; case TIMER_TYPE_SCANLINE: if (m_period != 0 || m_start_delay != 0) mame_printf_warning("%s: %s scanline timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); if (m_param != 0) mame_printf_warning("%s: %s scanline timer '%s' specified parameter which is ignored\n", driver.source_file, driver.name, tag()); if (m_first_vpos < 0) { mame_printf_error("%s: %s scanline timer '%s' specified invalid initial position\n", driver.source_file, driver.name, tag()); error = true; } if (m_increment < 0) { mame_printf_error("%s: %s scanline timer '%s' specified invalid increment\n", driver.source_file, driver.name, tag()); error = true; } break; default: mame_printf_error("%s: %s timer '%s' has an invalid type\n", driver.source_file, driver.name, tag()); error = true; break; } return error; }
bool cheat_manager::save_all(const char *filename) { // open the file with the proper name emu_file cheatfile(machine().options().cheat_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); file_error filerr = cheatfile.open(filename, ".xml"); // if that failed, return nothing if (filerr != FILERR_NONE) return false; // wrap the rest of catch errors try { // output the outer layers cheatfile.printf("<?xml version=\"1.0\"?>\n"); cheatfile.printf("<!-- This file is autogenerated; comments and unknown tags will be stripped -->\n"); cheatfile.printf("<mamecheat version=\"%d\">\n", CHEAT_VERSION); // iterate over cheats in the list and save them for (cheat_entry *cheat = m_cheatlist.first(); cheat != NULL; cheat = cheat->next()) cheat->save(cheatfile); // close out the file cheatfile.printf("</mamecheat>\n"); return true; } // catch errors and cleanup catch (emu_fatalerror &err) { mame_printf_error("%s\n", err.string()); cheatfile.remove_on_close(); } return false; }
void device_sound_interface::interface_validity_check(validity_checker &valid) const { // loop over all the routes for (const sound_route *route = first_route(); route != NULL; route = route->next()) { // find a device with the requested tag const device_t *target = device().siblingdevice(route->m_target.cstr()); if (target == NULL) mame_printf_error("Attempting to route sound to non-existant device '%s'\n", route->m_target.cstr()); // if it's not a speaker or a sound device, error const device_sound_interface *sound; if (target != NULL && target->type() != SPEAKER && !target->get_interface(sound)) mame_printf_error("Attempting to route sound to a non-sound device '%s' (%s)\n", route->m_target.cstr(), target->name()); } }
static int ddraw_create(win_window_info *window) { dd_info *dd = window->drawdata; HRESULT result; int verify; // if a device exists, free it if (dd->ddraw != NULL) ddraw_delete(window); // create the DirectDraw object result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, &IID_IDirectDraw7, NULL); if (result != DD_OK) { mame_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); goto error; } // verify the caps verify = ddraw_verify_caps(dd); if (verify == 2) { mame_printf_error("DirectDraw: Error - Device does not meet minimum requirements for DirectDraw rendering\n"); goto error; } if (verify == 1) mame_printf_verbose("DirectDraw: Warning - Device may not perform well for DirectDraw rendering\n"); // set the cooperative level // for non-window modes, we will use full screen here result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, win_window_list->hwnd, DDSCL_SETFOCUSWINDOW); if (result != DD_OK) { mame_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(FOCUSWINDOW) call\n", (int)result); goto error; } result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->hwnd, DDSCL_SETDEVICEWINDOW | (window->fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL)); if (result != DD_OK) { mame_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(DEVICEWINDOW) call\n", (int)result); goto error; } // full screen mode: set the resolution if (window->fullscreen && video_config.switchres) { result = IDirectDraw7_SetDisplayMode(dd->ddraw, dd->width, dd->height, 32, dd->refresh, 0); if (result != DD_OK) { mame_printf_verbose("DirectDraw: Error %08X attempting to set video mode %dx%d@%d call\n", (int)result, dd->width, dd->height, dd->refresh); goto error; } } return ddraw_create_surfaces(window); error: ddraw_delete(window); return 1; }
void device_execute_interface::interface_validity_check(validity_checker &valid) const { // validate the interrupts if (!m_vblank_interrupt.isnull() || m_vblank_interrupt_legacy != NULL) { screen_device_iterator iter(device().mconfig().root_device()); if (iter.first() == NULL) mame_printf_error("VBLANK interrupt specified, but the driver is screenless\n"); else if (m_vblank_interrupt_screen != NULL && device().siblingdevice(m_vblank_interrupt_screen) == NULL) mame_printf_error("VBLANK interrupt references a non-existant screen tag '%s'\n", m_vblank_interrupt_screen); } if ((!m_timed_interrupt.isnull() || m_timed_interrupt_legacy != NULL) && m_timed_interrupt_period == attotime::zero) mame_printf_error("Timed interrupt handler specified with 0 period\n"); else if ((m_timed_interrupt.isnull() && m_timed_interrupt_legacy == NULL) && m_timed_interrupt_period != attotime::zero) mame_printf_error("No timer interrupt handler specified, but has a non-0 period given\n"); }
bool finder_base::report_missing(bool found, const char *objname, bool required) { if (required && strcmp(m_tag, FINDER_DUMMY_TAG)==0) { mame_printf_error("Tag not defined for required device\n"); return false; } // just pass through in the found case if (found) return true; // otherwise, report if (required) mame_printf_error("Required %s '%s' not found\n", objname, m_tag); else mame_printf_verbose("Optional %s '%s' not found\n", objname, m_tag); return !required; }
bool t6a04_device::device_validity_check( const game_driver &driver ) const { bool error = false; if (height == 0 || width == 0) { mame_printf_error("%s: %s device '%s' has invalid parameter\n", driver.source_file, driver.name, tag()); error = true; } return error; }
static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error) { config->width = config->height = config->refresh = 0; if (strcmp(data, "auto") == 0) { if (strcmp(defdata, "auto") == 0) return; data = defdata; } if (sscanf(data, "%dx%d@%d", &config->width, &config->height, &config->refresh) < 2 && report_error) mame_printf_error("Illegal resolution value = %s\n", data); }
bool eeprom_device_config::device_validity_check(const game_driver &driver) const { bool error = false; if (m_data_bits != 8 && m_data_bits != 16) { mame_printf_error("%s: %s eeprom device '%s' specified invalid data width %d\n", driver.source_file, driver.name, tag(), m_data_bits); error = true; } return error; }
int options_get_bool(const char *name) { options_data *data = find_entry_data(name, FALSE); int value = FALSE; if (data == NULL) mame_printf_error("Unexpected boolean option %s queried\n", name); else if (data->data == NULL || sscanf(data->data, "%d", &value) != 1 || value < 0 || value > 1) { if (data->defdata != NULL) { options_set_string(name, data->defdata); sscanf(data->data, "%d", &value); } if (!data->error_reported) { mame_printf_error("Illegal boolean value for %s; reverting to %d\n", data->names[0], value); data->error_reported = TRUE; } } return value; }
float options_get_float(const char *name) { options_data *data = find_entry_data(name, FALSE); float value = 0; if (data == NULL) mame_printf_error("Unexpected float option %s queried\n", name); else if (data->data == NULL || sscanf(data->data, "%f", &value) != 1) { if (data->defdata != NULL) { options_set_string(name, data->defdata); sscanf(data->data, "%f", &value); } if (!data->error_reported) { mame_printf_error("Illegal float value for %s; reverting to %f\n", data->names[0], (double)value); data->error_reported = TRUE; } } return value; }
static int nvram_system_load( running_machine &machine, const char *name, nvram_load_func _nvram_load, int required) { emu_file *file; file = nvram_system_fopen( machine, OPEN_FLAG_READ, name); if (!file) { if (required) mame_printf_error( "nvram load failed (%s)\n", name); return FALSE; } (*_nvram_load)(machine, file); global_free(file); return TRUE; }
static int nvram_system_save( running_machine &machine, const char *name, nvram_save_func _nvram_save) { emu_file *file; file = nvram_system_fopen( machine, OPEN_FLAG_CREATE | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE_PATHS, name); if (!file) { mame_printf_error( "nvram save failed (%s)\n", name); return FALSE; } (*_nvram_save)(machine, file); global_free(file); return TRUE; }
static float get_aspect(const char *defdata, const char *data, int report_error) { int num = 0, den = 1; if (strcmp(data, "auto") == 0) { if (strcmp(defdata, "auto") == 0) return 0; data = defdata; } if (sscanf(data, "%d:%d", &num, &den) != 2 && report_error) mame_printf_error("Illegal aspect ratio value = %s\n", data); return (float)num / (float)den; }
static void fatalerror_common(running_machine *machine, int exitcode, const char *buffer) { /* output and return */ mame_printf_error("%s\n", giant_string_buffer); /* break into the debugger if attached */ osd_break_into_debugger(giant_string_buffer); /* longjmp back if we can; otherwise, exit */ if (machine != NULL && machine->mame_data != NULL && machine->mame_data->fatal_error_jmpbuf_valid) longjmp(machine->mame_data->fatal_error_jmpbuf, exitcode); else exit(exitcode); }
static void get_resolution(core_options &options, const char *name, win_window_config *config, int report_error) { const char *defdata = options_get_string(&options, WINOPTION_RESOLUTION); const char *data = options_get_string(&options, name); config->width = config->height = config->refresh = 0; if (strcmp(data, "auto") == 0) { if (strcmp(defdata, "auto") == 0) return; data = defdata; } if (sscanf(data, "%dx%d@%d", &config->width, &config->height, &config->refresh) < 2 && report_error) mame_printf_error("Illegal resolution value for %s = %s\n", name, data); }
static float get_aspect(core_options &options, const char *name, int report_error) { const char *defdata = options_get_string(&options, WINOPTION_ASPECT); const char *data = options_get_string(&options, name); int num = 0, den = 1; if (strcmp(data, "auto") == 0) { if (strcmp(defdata, "auto") == 0) return 0; data = defdata; } if (sscanf(data, "%d:%d", &num, &den) != 2 && report_error) mame_printf_error("Illegal aspect ratio value for %s = %s\n", name, data); return (float)num / (float)den; }
static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error) { config->width = config->height = config->depth = config->refresh = 0; if (strcmp(data, SDLOPTVAL_AUTO) == 0) { if (strcmp(defdata, SDLOPTVAL_AUTO) == 0) { return; } data = defdata; } if (sscanf(data, "%dx%dx%d@%lf", &config->width, &config->height, &config->depth, &config->refresh) < 2 && report_error) mame_printf_error("Illegal resolution value = %s\n", data); }
bool device_config_execute_interface::interface_validity_check(core_options &options, const game_driver &driver) const { const device_config *devconfig = crosscast<const device_config *>(this); bool error = false; /* validate the interrupts */ if (m_vblank_interrupt != NULL) { if (m_machine_config.m_devicelist.count(SCREEN) == 0) { mame_printf_error("%s: %s device '%s' has a VBLANK interrupt, but the driver is screenless!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } else if (m_vblank_interrupt_screen != NULL && m_vblank_interrupts_per_frame != 0) { mame_printf_error("%s: %s device '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } else if (m_vblank_interrupt_screen != NULL && m_machine_config.m_devicelist.find(m_vblank_interrupt_screen) == NULL) { mame_printf_error("%s: %s device '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver.source_file, driver.name, devconfig->tag(), m_vblank_interrupt_screen); error = true; } else if (m_vblank_interrupt_screen == NULL && m_vblank_interrupts_per_frame == 0) { mame_printf_error("%s: %s device '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } } else if (m_vblank_interrupts_per_frame != 0) { mame_printf_error("%s: %s device '%s' has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } if (m_timed_interrupt != NULL && m_timed_interrupt_period == attotime::zero) { mame_printf_error("%s: %s device '%s' has a timer interrupt handler with 0 period!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } else if (m_timed_interrupt == NULL && m_timed_interrupt_period != attotime::zero) { mame_printf_error("%s: %s device '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } return error; }
static OSDWORK_CALLBACK(sdlwindow_thread_id) { window_threadid = SDL_ThreadID(); if (SDLMAME_INIT_IN_WORKER_THREAD) { #if (SDLMAME_SDL2) if (SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) #else if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) #endif { mame_printf_error("Could not initialize SDL: %s.\n", SDL_GetError()); exit(-1); } } return NULL; }
int cli_info_listsamples(core_options *options, const char *gamename) { int count = 0; #if (HAS_SAMPLES) int drvindex; /* since we expand the machine driver, we need to set things up */ init_resource_tracking(); cpuintrf_init(NULL); sndintrf_init(NULL); /* iterate over drivers */ for (drvindex = 0; drivers[drvindex]; drvindex++) if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0) { machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config); int sndnum; /* find samples interfaces */ for (sndnum = 0; sndnum < MAX_SOUND && config->sound[sndnum].type != SOUND_DUMMY; sndnum++) if (config->sound[sndnum].type == SOUND_SAMPLES) { const char *const *samplenames = ((const struct Samplesinterface *)config->sound[sndnum].config)->samplenames; int sampnum; /* if the list is legit, walk it and print the sample info */ if (samplenames != NULL) for (sampnum = 0; samplenames[sampnum] != NULL; sampnum++) mame_printf_info("%s\n", samplenames[sampnum]); } count++; machine_config_free(config); } /* clean up our tracked resources */ exit_resource_tracking(); #else mame_printf_error("Samples not supported in this build\n"); #endif return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME; }