void timer_device::device_validity_check(validity_checker &valid) const { // type based configuration switch (m_type) { case TIMER_TYPE_GENERIC: if (m_screen_tag != nullptr || m_first_vpos != 0 || m_start_delay != attotime::zero) osd_printf_warning("Generic timer specified parameters for a scanline timer\n"); if (m_period != attotime::zero || m_start_delay != attotime::zero) osd_printf_warning("Generic timer specified parameters for a periodic timer\n"); break; case TIMER_TYPE_PERIODIC: if (m_screen_tag != nullptr || m_first_vpos != 0) osd_printf_warning("Periodic timer specified parameters for a scanline timer\n"); if (m_period <= attotime::zero) osd_printf_error("Periodic timer specified invalid period\n"); break; case TIMER_TYPE_SCANLINE: if (m_period != attotime::zero || m_start_delay != attotime::zero) osd_printf_warning("Scanline timer specified parameters for a periodic timer\n"); if (m_param != 0) osd_printf_warning("Scanline timer specified parameter which is ignored\n"); // if (m_first_vpos < 0) // osd_printf_error("Scanline timer specified invalid initial position\n"); // if (m_increment < 0) // osd_printf_error("Scanline timer specified invalid increment\n"); break; default: osd_printf_error("Invalid type specified\n"); break; } }
void *finder_base::find_memregion(u8 width, size_t &length, bool required) const { // look up the region and return nullptr if not found memory_region *const region(m_base.get().memregion(m_tag)); if (!region) { length = 0; return nullptr; } // check the width and warn if not correct if (region->bytewidth() != width) { if (required) osd_printf_warning("Region '%s' found but is width %d, not %d as requested\n", m_tag, region->bitwidth(), width*8); length = 0; return nullptr; } // check the length and warn if other than specified size_t const length_found = region->bytes() / width; if (length != 0 && length != length_found) { if (required) osd_printf_warning("Region '%s' found but has %d bytes, not %ld as requested\n", m_tag, region->bytes(), long(length*width)); length = 0; return nullptr; } // return results length = length_found; return region->base(); }
address_map_entry::address_map_entry(device_t &device, address_map &map, offs_t start, offs_t end) : m_next(nullptr), m_map(map), m_devbase(device), m_addrstart(start), m_addrend(end), m_addrmirror(0), m_addrmask(0), m_addrselect(0), m_share(nullptr), m_region(nullptr), m_rgnoffs(0), m_submap_bits(0), m_memory(nullptr), m_bytestart(0), m_byteend(0), m_bytemirror(0), m_bytemask(0) { if (map.m_globalmask != 0 && (start & ~map.m_globalmask) != 0) { osd_printf_warning("AS_%d map entry start %08X lies outside global address mask %08X\n", map.m_spacenum, start, map.m_globalmask); m_addrstart &= map.m_globalmask; } if (map.m_globalmask != 0 && (end & ~map.m_globalmask) != 0) { osd_printf_warning("AS_%d map entry end %08X lies outside global address mask %08X\n", map.m_spacenum, end, map.m_globalmask); m_addrend &= map.m_globalmask; } }
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 cheat_script::script_entry::execute(cheat_manager &manager, uint64_t &argindex) { // evaluate the condition if (!m_condition.is_empty()) { try { uint64_t result = m_condition.execute(); if (result == 0) return; } catch (expression_error &err) { osd_printf_warning("Error executing conditional expression \"%s\": %s\n", m_condition.original_string(), err.code_string()); return; } } // if there is an action, execute it if (!m_expression.is_empty()) { try { m_expression.execute(); } catch (expression_error &err) { osd_printf_warning("Error executing expression \"%s\": %s\n", m_expression.original_string(), err.code_string()); } } // if there is a string to display, compute it if (!m_format.empty()) { // iterate over arguments and evaluate them uint64_t params[MAX_ARGUMENTS]; int curarg = 0; for (auto &arg : m_arglist) curarg += arg->values(argindex, ¶ms[curarg]); // generate the astring manager.get_output_string(m_line, m_justify) = string_format(m_format, (uint32_t)params[0], (uint32_t)params[1], (uint32_t)params[2], (uint32_t)params[3], (uint32_t)params[4], (uint32_t)params[5], (uint32_t)params[6], (uint32_t)params[7], (uint32_t)params[8], (uint32_t)params[9], (uint32_t)params[10], (uint32_t)params[11], (uint32_t)params[12], (uint32_t)params[13], (uint32_t)params[14], (uint32_t)params[15], (uint32_t)params[16], (uint32_t)params[17], (uint32_t)params[18], (uint32_t)params[19], (uint32_t)params[20], (uint32_t)params[21], (uint32_t)params[22], (uint32_t)params[23], (uint32_t)params[24], (uint32_t)params[25], (uint32_t)params[26], (uint32_t)params[27], (uint32_t)params[28], (uint32_t)params[29], (uint32_t)params[30], (uint32_t)params[31]); } }
void cheat_script::script_entry::execute(cheat_manager &manager, UINT64 &argindex) { // evaluate the condition if (!m_condition.is_empty()) { try { UINT64 result = m_condition.execute(); if (result == 0) return; } catch (expression_error &err) { osd_printf_warning("Error executing conditional expression \"%s\": %s\n", m_condition.original_string(), err.code_string()); return; } } // if there is an action, execute it if (!m_expression.is_empty()) { try { m_expression.execute(); } catch (expression_error &err) { osd_printf_warning("Error executing expression \"%s\": %s\n", m_expression.original_string(), err.code_string()); } } // if there is a string to display, compute it if (!m_format.empty()) { // iterate over arguments and evaluate them UINT64 params[MAX_ARGUMENTS]; int curarg = 0; for (output_argument *arg = m_arglist.first(); arg != nullptr; arg = arg->next()) curarg += arg->values(argindex, ¶ms[curarg]); // generate the astring strprintf(manager.get_output_astring(m_line, m_justify), m_format.c_str(), (UINT32)params[0], (UINT32)params[1], (UINT32)params[2], (UINT32)params[3], (UINT32)params[4], (UINT32)params[5], (UINT32)params[6], (UINT32)params[7], (UINT32)params[8], (UINT32)params[9], (UINT32)params[10], (UINT32)params[11], (UINT32)params[12], (UINT32)params[13], (UINT32)params[14], (UINT32)params[15], (UINT32)params[16], (UINT32)params[17], (UINT32)params[18], (UINT32)params[19], (UINT32)params[20], (UINT32)params[21], (UINT32)params[22], (UINT32)params[23], (UINT32)params[24], (UINT32)params[25], (UINT32)params[26], (UINT32)params[27], (UINT32)params[28], (UINT32)params[29], (UINT32)params[30], (UINT32)params[31]); } }
cheat_script::cheat_script(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node const &scriptnode) : m_state(SCRIPT_STATE_RUN) { // read the core attributes const char *state = scriptnode.get_attribute_string("state", "run"); if (strcmp(state, "on") == 0) m_state = SCRIPT_STATE_ON; else if (strcmp(state, "off") == 0) m_state = SCRIPT_STATE_OFF; else if (strcmp(state, "change") == 0) m_state = SCRIPT_STATE_CHANGE; else if (strcmp(state, "run") != 0) throw emu_fatalerror("%s.xml(%d): invalid script state '%s'\n", filename, scriptnode.line, state); // iterate over nodes within the script for (xml_data_node const *entrynode = scriptnode.get_first_child(); entrynode != nullptr; entrynode = entrynode->get_next_sibling()) { // handle action nodes if (strcmp(entrynode->get_name(), "action") == 0) m_entrylist.push_back(std::make_unique<script_entry>(manager, symbols, filename, *entrynode, true)); // handle output nodes else if (strcmp(entrynode->get_name(), "output") == 0) m_entrylist.push_back(std::make_unique<script_entry>(manager, symbols, filename, *entrynode, false)); // anything else is ignored else { osd_printf_warning("%s.xml(%d): unknown script item '%s' will be lost if saved\n", filename, entrynode->line, entrynode->get_name()); continue; } } }
cheat_script::cheat_script(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &scriptnode) : m_state(SCRIPT_STATE_RUN) { // read the core attributes const char *state = xml_get_attribute_string(&scriptnode, "state", "run"); if (strcmp(state, "on") == 0) m_state = SCRIPT_STATE_ON; else if (strcmp(state, "off") == 0) m_state = SCRIPT_STATE_OFF; else if (strcmp(state, "change") == 0) m_state = SCRIPT_STATE_CHANGE; else if (strcmp(state, "run") != 0) throw emu_fatalerror("%s.xml(%d): invalid script state '%s'\n", filename, scriptnode.line, state); // iterate over nodes within the script for (xml_data_node *entrynode = scriptnode.child; entrynode != NULL; entrynode = entrynode->next) { // handle action nodes if (strcmp(entrynode->name, "action") == 0) m_entrylist.append(*global_alloc(script_entry(manager, symbols, filename, *entrynode, true))); // handle output nodes else if (strcmp(entrynode->name, "output") == 0) m_entrylist.append(*global_alloc(script_entry(manager, symbols, filename, *entrynode, false))); // anything else is ignored else { osd_printf_warning("%s.xml(%d): unknown script item '%s' will be lost if saved\n", filename, entrynode->line, entrynode->name); continue; } } }
bool finder_base::validate_memregion(size_t bytes, bool required) const { // make sure we can resolve the full path to the region size_t bytes_found = 0; std::string const region_fulltag(m_base.get().subtag(m_tag)); // look for the region for (device_t const &dev : device_iterator(m_base.get().mconfig().root_device())) { for (romload::region const ®ion : romload::entries(dev.rom_region()).get_regions()) { if (dev.subtag(region.get_tag()) == region_fulltag) { bytes_found = region.get_length(); break; } } if (bytes_found != 0) break; } // check the length and warn if other than specified if ((bytes_found != 0) && (bytes != 0) && (bytes != bytes_found)) { osd_printf_warning("Region '%s' found but has %ld bytes, not %ld as requested\n", m_tag, long(bytes_found), long(bytes)); bytes_found = 0; } return report_missing(bytes_found != 0, "memory region", required); }
void tcp_connection::write(const uint8_t* data, size_t len) { if (m_is_closing) return; if (len == 0) return; uv_buf_t buffer; int written; int err; // First try uv_try_write(). In case it can not directly write all the given // data then build a uv_req_t and use uv_write(). buffer = uv_buf_init((char*)data, len); written = uv_try_write((uv_stream_t*)m_uv_handle, &buffer, 1); // All the data was written. Done. if (written == (int)len) { return; } // Cannot write any data at first time. Use uv_write(). else if (written == UV_EAGAIN || written == UV_ENOSYS) { // Set written to 0 so pending_len can be properly calculated. written = 0; } // Error. Should not happen. else if (written < 0) { osd_printf_warning("uv_try_write() failed, closing the connection: %s\n", uv_strerror(written)); close(); return; } // osd_printf_info("could just write %zu bytes (%zu given) at first time, using uv_write() now", (size_t)written, len); size_t pending_len = len - written; // Allocate a special UvWriteData struct pointer. tcp_uv_write_data* write_data = (tcp_uv_write_data*)std::malloc(sizeof(tcp_uv_write_data) + pending_len); write_data->connection = this; std::memcpy(write_data->store, data + written, pending_len); write_data->req.data = (void*)write_data; buffer = uv_buf_init((char*)write_data->store, pending_len); err = uv_write(&write_data->req, (uv_stream_t*)m_uv_handle, &buffer, 1, (uv_write_cb)on_write); if (err) throw emu_fatalerror("uv_write() failed: %s", uv_strerror(err)); }
void finder_base::printf_warning(const char *format, ...) { va_list argptr; char buffer[1024]; /* do the output */ va_start(argptr, format); vsnprintf(buffer, 1024, format, argptr); osd_printf_warning("%s", buffer); va_end(argptr); }
bool osd_interface::sound_init() { osd_sound_type sound = m_sound_options.find(machine().options().sound()); if (sound==NULL) { osd_printf_warning("sound_init: option %s not found switching to auto\n",machine().options().sound()); sound = m_sound_options.find("auto"); } m_sound = (*sound)(*this); return true; }
static void sdlwindow_sync(void) { if (multithreading_enabled) { // Fallback while (!osd_work_queue_wait(work_queue, osd_ticks_per_second()*10)) { osd_printf_warning("sdlwindow_sync: Sleeping...\n"); osd_sleep(100000); } } }
int gl_check_error(GLSLCheckMode m, const char *file, const int line) { GLenum glerr = glGetError(); if (GL_NO_ERROR != glerr) { if ( CHECK_VERBOSE <= m ) { osd_printf_warning( "%s:%d: GL Error: %d 0x%X\n", file, line, (int)glerr, (unsigned int)glerr); } } return (GL_NO_ERROR != glerr)? glerr : 0; }
bool device_image_interface::load_software_part(const char *path, software_part *&swpart) { // if no match has been found, we suggest similar shortnames swpart = find_software_item(path, true); if (swpart == NULL) { software_list_device::display_matches(device().machine().config(), image_interface(), path); return false; } // Load the software part bool result = call_softlist_load(swpart->info().list(), swpart->info().shortname(), swpart->romdata()); // Tell the world which part we actually loaded astring full_sw_name; full_sw_name.printf("%s:%s:%s", swpart->info().list().list_name(), swpart->info().shortname(), swpart->name()); // check compatibility if (!swpart->is_compatible(swpart->info().list())) osd_printf_warning("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n", swpart->info().shortname(), swpart->info().list().filter()); // check requirements and load those images const char *requirement = swpart->feature("requirement"); if (requirement != NULL) { software_part *req_swpart = find_software_item(requirement, false); if (req_swpart != NULL) { image_interface_iterator imgiter(device().machine().root_device()); for (device_image_interface *req_image = imgiter.first(); req_image != NULL; req_image = imgiter.next()) { const char *interface = req_image->image_interface(); if (interface != NULL) { if (req_swpart->matches_interface(interface)) { const char *option = device().mconfig().options().value(req_image->brief_instance_name()); // mount only if not already mounted if (strlen(option) == 0 && !req_image->filename()) { req_image->set_init_phase(); req_image->load(requirement); } break; } } } } } return result; }
device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, UINT32 clock) { // find the original device by this name (must exist) assert(owner != NULL); device_t *device = owner->subdevice(tag); if (device == NULL) { osd_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag); return device_add(owner, tag, type, clock); } // let the device's owner do the work return device->owner()->replace_subdevice(*device, type, tag, clock); }
std::tuple<const char *, device_t *, device_t *> machine_config::prepare_replace(const char *tag) { // make sure we have the old device's actual owner std::pair<const char *, device_t *> const owner(resolve_owner(tag)); assert(owner.second); // remove references to the old device device_t *const old_device(owner.second->subdevice(owner.first)); if (old_device) remove_references(*old_device); else osd_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag); return std::make_tuple(owner.first, owner.second, old_device); }
device_t *machine_config::device_remove(device_t *owner, const char *tag) { // find the original device by this name (must exist) assert(owner != NULL); device_t *device = owner->subdevice(tag); if (device == NULL) { osd_printf_warning("Warning: attempting to remove non-existent device '%s'\n", tag); return NULL; } // let the device's owner do the work device->owner()->remove_subdevice(*device); return NULL; }
int cheat_script::script_entry::output_argument::values(uint64_t &argindex, uint64_t *result) { for (argindex = 0; argindex < m_count; argindex++) { try { result[argindex] = m_expression.execute(); } catch (expression_error &err) { osd_printf_warning("Error executing argument expression \"%s\": %s\n", m_expression.original_string(), err.code_string()); } } return m_count; }
void osd_interface::init_debugger() { // // Unlike init() above, this method is only called if the debugger // is active. This gives any OSD debugger interface a chance to // create all of its structures. // osd_debugger_type debugger = m_debugger_options.find(machine().options().debugger()); if (debugger==NULL) { osd_printf_warning("debugger_init: option %s not found switching to auto\n",machine().options().debugger()); debugger = m_debugger_options.find("auto"); } m_debugger = (*debugger)(*this); m_debugger->init_debugger(); }
static inline SDL_BlendMode map_blendmode(const int blendmode) { switch (blendmode) { case BLENDMODE_NONE: return SDL_BLENDMODE_NONE; case BLENDMODE_ALPHA: return SDL_BLENDMODE_BLEND; case BLENDMODE_RGB_MULTIPLY: return SDL_BLENDMODE_MOD; case BLENDMODE_ADD: return SDL_BLENDMODE_ADD; default: osd_printf_warning("Unknown Blendmode %d", blendmode); } return SDL_BLENDMODE_NONE; }
void *finder_base::find_memshare(u8 width, size_t &bytes, bool required) const { // look up the share and return nullptr if not found memory_share *const share(m_base.get().memshare(m_tag)); if (!share) return nullptr; // check the width and warn if not correct if (width != 0 && share->bitwidth() != width) { if (required) osd_printf_warning("Shared ptr '%s' found but is width %d, not %d as requested\n", m_tag, share->bitwidth(), width); return nullptr; } // return results bytes = share->bytes(); return share->ptr(); }
// 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>"); }
void savquest_state::pci_3dfx_w(int function, int reg, uint32_t data, uint32_t mem_mask) { osd_printf_warning("PCI write: %x %x\n", reg, data); if (reg == 0x10) { data &= 0xff000000; } else if (reg == 0x40) { m_voodoo->voodoo_set_init_enable(data); } else if (reg == 0x54) { data &= 0xf000ffff; /* bits 16-27 are read-only */ } m_pci_3dfx_regs[reg / 4] = data; }
void tcp_connection::on_uv_read_alloc(size_t suggested_size, uv_buf_t* buf) { // If this is the first call to onUvReadAlloc() then allocate the receiving buffer now. if (!m_buffer) m_buffer = new uint8_t[m_buffer_size]; // Tell UV to write after the last data byte in the buffer. buf->base = (char *)(m_buffer + m_buffer_data_len); // Give UV all the remaining space in the buffer. if (m_buffer_size > m_buffer_data_len) { buf->len = m_buffer_size - m_buffer_data_len; } else { buf->len = 0; osd_printf_warning("no available space in the buffer\n"); } }
void rom_load_manager::display_rom_load_results(bool from_list) { /* final status display */ display_loading_rom_message(nullptr, from_list); /* if we had errors, they are fatal */ if (m_errors != 0) { /* create the error message and exit fatally */ osd_printf_error("%s", m_errorstring.c_str()); fatalerror_exitcode(machine(), MAMERR_MISSING_FILES, "Required files are missing, the machine cannot be run."); } /* if we had warnings, output them, but continue */ if ((m_warnings) || (m_knownbad)) { m_errorstring.append("WARNING: the machine might not run correctly."); osd_printf_warning("%s\n", m_errorstring.c_str()); } }
void vlog(const plib::plog_level &l, const pstring &ls) const override { switch (l) { case plib::plog_level::DEBUG: break; case plib::plog_level::VERBOSE: break; case plib::plog_level::INFO: osd_printf_verbose("netlist INFO: %s\n", ls.c_str()); break; case plib::plog_level::WARNING: osd_printf_warning("netlist WARNING: %s\n", ls.c_str()); break; case plib::plog_level::ERROR: osd_printf_error("netlist ERROR: %s\n", ls.c_str()); break; case plib::plog_level::FATAL: throw emu_fatalerror(1, "netlist FATAL: %s\n", ls.c_str()); } }
device_t *machine_config::device_remove(device_t *owner, const char *tag) { // find the original device by relative tag (must exist) assert(owner != nullptr); device_t *device = owner->subdevice(tag); if (device == nullptr) { osd_printf_warning("Warning: attempting to remove non-existent device '%s'\n", tag); return nullptr; } // make sure we have the old device's actual owner owner = device->owner(); assert(owner != nullptr); // remove references to the old device remove_references(*device); // let the device's owner do the work owner->subdevices().m_list.remove(*device); return nullptr; }
static void display_rom_load_results(romload_private *romdata, bool from_list) { /* final status display */ display_loading_rom_message(romdata, NULL, from_list); /* if we had errors, they are fatal */ if (romdata->errors != 0) { /* create the error message and exit fatally */ osd_printf_error("%s", romdata->errorstring.cstr()); fatalerror_exitcode(romdata->machine(), MAMERR_MISSING_FILES, "Required files are missing, the %s cannot be run.",emulator_info::get_gamenoun()); } /* if we had warnings, output them, but continue */ if ((romdata-> warnings) || (romdata->knownbad)) { romdata->errorstring.cat("WARNING: the "); romdata->errorstring.cat(emulator_info::get_gamenoun()); romdata->errorstring.cat(" might not run correctly."); osd_printf_warning("%s\n", romdata->errorstring.cstr()); } }
device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, UINT32 clock) { // find the original device by relative tag (must exist) assert(owner != nullptr); device_t *old_device = owner->subdevice(tag); if (old_device == nullptr) { osd_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag); return device_add(owner, tag, type, clock); } // make sure we have the old device's actual owner owner = old_device->owner(); assert(owner != nullptr); // remove references to the old device remove_references(*old_device); // allocate the new device device_t *new_device = (*type)(*this, tag, owner, clock); // substitute it for the old one in the owner's list return &config_new_device(owner->subdevices().m_list.replace_and_remove(*new_device, *old_device)); }