static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, int width, int height) { // swap the coordinates back if they were talking about a rotated surface if (state.tilemap.rotate & ORIENTATION_SWAP_XY) std::swap(width, height); // realloc the bitmap if it is too small if (state.bitmap == nullptr || state.texture == nullptr || state.bitmap->width() != width || state.bitmap->height() != height) { // free the old stuff machine.render().texture_free(state.texture); global_free(state.bitmap); // allocate new stuff state.bitmap = global_alloc(bitmap_rgb32(width, height)); state.texture = machine.render().texture_alloc(); state.texture->set_bitmap(*state.bitmap, state.bitmap->cliprect(), TEXFORMAT_RGB32); // force a redraw state.bitmap_dirty = true; } // handle the redraw if (state.bitmap_dirty) { state.bitmap->fill(0); tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which); tilemap->draw_debug(*machine.first_screen(), *state.bitmap, state.tilemap.xoffs, state.tilemap.yoffs, state.tilemap.flags); // reset the texture to force an update state.texture->set_bitmap(*state.bitmap, state.bitmap->cliprect(), TEXFORMAT_RGB32); state.bitmap_dirty = false; } }
void crosshair_init(running_machine &machine) { /* request a callback upon exiting */ machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(crosshair_exit), &machine)); /* clear all the globals */ memset(&global, 0, sizeof(global)); /* setup the default auto visibility time */ global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ for (ioport_port *port = machine.ioport().first_port(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) if (field->crosshair_axis() != CROSSHAIR_AXIS_NONE) { int player = field->player(); assert(player < MAX_PLAYERS); /* mark as used and set the default visibility and mode */ global.usage = TRUE; global.used[player] = TRUE; global.mode[player] = CROSSHAIR_VISIBILITY_DEFAULT; global.visible[player] = (CROSSHAIR_VISIBILITY_DEFAULT == CROSSHAIR_VISIBILITY_OFF) ? FALSE : TRUE; /* for now, use the main screen */ global.screen[player] = machine.first_screen(); create_bitmap(machine, player); } /* register callbacks for when we load/save configurations */ if (global.usage) config_register(machine, "crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine)); /* register the animation callback */ if (machine.first_screen() != NULL) machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(animate), &machine)); }
ui_menu_autofire::ui_menu_autofire(running_machine &machine, render_container *container) : ui_menu(machine, container), last_toggle(false) { const screen_device *screen = machine.first_screen(); if (screen == nullptr) { refresh = 60.0; } else { refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds()); } }
crosshair_manager::crosshair_manager(running_machine &machine) : m_machine(machine) { /* request a callback upon exiting */ machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(crosshair_manager::exit), this)); /* setup the default auto visibility time */ m_auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ for (auto &port : machine.ioport().ports()) for (ioport_field &field : port.second->fields()) if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE) { int player = field.player(); assert(player < MAX_PLAYERS); /* mark as used and set the default visibility and mode */ m_usage = TRUE; m_used[player] = TRUE; m_mode[player] = CROSSHAIR_VISIBILITY_DEFAULT; m_visible[player] = (CROSSHAIR_VISIBILITY_DEFAULT == CROSSHAIR_VISIBILITY_OFF) ? FALSE : TRUE; /* for now, use the main screen */ m_screen[player] = machine.first_screen(); create_bitmap(player); } /* register callbacks for when we load/save configurations */ if (m_usage) machine.configuration().config_register("crosshairs", config_saveload_delegate(FUNC(crosshair_manager::config_load), this), config_saveload_delegate(FUNC(crosshair_manager::config_save), this)); /* register the animation callback */ if (machine.first_screen() != nullptr) machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(crosshair_manager::animate), this)); }
crosshair_manager::crosshair_manager(running_machine &machine) : m_machine(machine) , m_usage(false) , m_animation_counter(0) , m_auto_time(CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT) { /* request a callback upon exiting */ machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&crosshair_manager::exit, this)); for (int player = 0; player < MAX_PLAYERS; player++) m_crosshair[player] = std::make_unique<render_crosshair>(machine, player); /* determine who needs crosshairs */ for (auto &port : machine.ioport().ports()) for (ioport_field &field : port.second->fields()) if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE) { int player = field.player(); assert(player < MAX_PLAYERS); /* mark as used and set the default visibility and mode */ m_usage = true; m_crosshair[player]->set_used(true); m_crosshair[player]->set_mode(CROSSHAIR_VISIBILITY_DEFAULT); m_crosshair[player]->set_visible(CROSSHAIR_VISIBILITY_DEFAULT != CROSSHAIR_VISIBILITY_OFF); m_crosshair[player]->set_default_bitmap(); } /* register callbacks for when we load/save configurations */ if (m_usage) machine.configuration().config_register("crosshairs", config_saveload_delegate(&crosshair_manager::config_load, this), config_saveload_delegate(&crosshair_manager::config_save, this)); /* register the animation callback */ if (machine.first_screen() != nullptr) machine.first_screen()->register_vblank_callback(vblank_state_delegate(&crosshair_manager::animate, this)); }
render_crosshair::render_crosshair(running_machine &machine, int player) : m_machine(machine) , m_player(player) , m_used(false) , m_mode(CROSSHAIR_VISIBILITY_OFF) , m_visible(false) , m_texture(nullptr) , m_x(0.0f) , m_y(0.0f) , m_last_x(0.0f) , m_last_y(0.0f) , m_time(0) { // for now, use the main screen m_screen = machine.first_screen(); }
/* call hiscore_open once after loading a game */ void hiscore_init (running_machine &machine) { memory_range *mem_range = state.mem_range; address_space *initspace; file_error filerr; const char *name = machine.system().name; state.hiscores_have_been_loaded = 0; while (mem_range) { if (strstr(machine.system().source_file,"cinemat.c") > 0) { initspace = &machine.cpu[mem_range->cpu]->memory().space(AS_DATA); initspace->write_byte(mem_range->addr, ~mem_range->start_value); initspace->write_byte(mem_range->addr + mem_range->num_bytes-1, ~mem_range->end_value); mem_range = mem_range->next; } else { initspace = &machine.cpu[mem_range->cpu]->memory().space(AS_PROGRAM); initspace->write_byte(mem_range->addr, ~mem_range->start_value); initspace->write_byte(mem_range->addr + mem_range->num_bytes-1, ~mem_range->end_value); mem_range = mem_range->next; } } state.mem_range = nullptr; emu_file f(machine.options().high_path(), OPEN_FLAG_READ); filerr = f.open("hiscore.dat"); if (filerr == FILERR_NONE) { char buffer[MAX_CONFIG_LINE_SIZE]; enum { FIND_NAME, FIND_DATA, FETCH_DATA } mode; mode = FIND_NAME; while (f.gets(buffer, MAX_CONFIG_LINE_SIZE)) { if (mode == FIND_NAME) { if (matching_game_name (buffer, name)) mode = FIND_DATA; } else if (is_mem_range (buffer)) { const char *pBuf = buffer; mem_range = (memory_range *)malloc(sizeof(memory_range)); if (mem_range) { mem_range->cpu = hexstr2num (&pBuf); mem_range->addr = hexstr2num (&pBuf); mem_range->num_bytes = hexstr2num (&pBuf); mem_range->start_value = hexstr2num (&pBuf); mem_range->end_value = hexstr2num (&pBuf); mem_range->next = nullptr; { memory_range *last = state.mem_range; while (last && last->next) last = last->next; if (last == nullptr) state.mem_range = mem_range; else last->next = mem_range; } mode = FETCH_DATA; } else { hiscore_free(); break; } } else { /* line is a game name */ if (mode == FETCH_DATA) break; } } f.close(); } timer = machine.scheduler().timer_alloc(FUNC(hiscore_periodic)); timer->adjust(machine.first_screen()->frame_period(), 0, machine.first_screen()->frame_period()); machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(hiscore_close), &machine)); }
video_manager::video_manager(running_machine &machine) : m_machine(machine), m_screenless_frame_timer(nullptr), m_output_changed(false), m_throttle_last_ticks(0), m_throttle_realtime(attotime::zero), m_throttle_emutime(attotime::zero), m_throttle_history(0), m_speed_last_realtime(0), m_speed_last_emutime(attotime::zero), m_speed_percent(1.0), m_overall_real_seconds(0), m_overall_real_ticks(0), m_overall_emutime(attotime::zero), m_overall_valid_counter(0), m_throttled(machine.options().throttle()), m_throttle_rate(1.0f), m_fastforward(false), m_seconds_to_run(machine.options().seconds_to_run()), m_auto_frameskip(machine.options().auto_frameskip()), m_speed(original_speed_setting()), m_empty_skip_count(0), m_frameskip_level(machine.options().frameskip()), m_frameskip_counter(0), m_frameskip_adjust(0), m_skipping_this_frame(false), m_average_oversleep(0), m_snap_target(nullptr), m_snap_native(true), m_snap_width(0), m_snap_height(0), m_mng_frame_period(attotime::zero), m_mng_next_frame_time(attotime::zero), m_mng_frame(0), m_avi_file(nullptr), m_avi_frame_period(attotime::zero), m_avi_next_frame_time(attotime::zero), m_avi_frame(0), m_dummy_recording(false), m_timecode_enabled(false), m_timecode_write(false), m_timecode_text(""), m_timecode_start(attotime::zero), m_timecode_total(attotime::zero) { // request a callback upon exiting machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(video_manager::exit), this)); machine.save().register_postload(save_prepost_delegate(FUNC(video_manager::postload), this)); // extract initial execution state from global configuration settings update_refresh_speed(); // create a render target for snapshots const char *viewname = machine.options().snap_view(); m_snap_native = (machine.first_screen() != nullptr && (viewname[0] == 0 || strcmp(viewname, "native") == 0)); // the native target is hard-coded to our internal layout and has all options disabled if (m_snap_native) { m_snap_target = machine.render().target_alloc(layout_snap, RENDER_CREATE_SINGLE_FILE | RENDER_CREATE_HIDDEN); m_snap_target->set_backdrops_enabled(false); m_snap_target->set_overlays_enabled(false); m_snap_target->set_bezels_enabled(false); m_snap_target->set_cpanels_enabled(false); m_snap_target->set_marquees_enabled(false); m_snap_target->set_screen_overlay_enabled(false); m_snap_target->set_zoom_to_screen(false); } // other targets select the specified view and turn off effects else { m_snap_target = machine.render().target_alloc(nullptr, RENDER_CREATE_HIDDEN); m_snap_target->set_view(m_snap_target->configured_view(viewname, 0, 1)); m_snap_target->set_screen_overlay_enabled(false); } // extract snap resolution if present if (sscanf(machine.options().snap_size(), "%dx%d", &m_snap_width, &m_snap_height) != 2) m_snap_width = m_snap_height = 0; // start recording movie if specified const char *filename = machine.options().mng_write(); if (filename[0] != 0) begin_recording(filename, MF_MNG); filename = machine.options().avi_write(); if (filename[0] != 0) begin_recording(filename, MF_AVI); #ifdef MAME_DEBUG m_dummy_recording = machine.options().dummy_write(); #endif // if no screens, create a periodic timer to drive updates if (machine.first_screen() == nullptr) { m_screenless_frame_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(video_manager::screenless_update_callback), this)); m_screenless_frame_timer->adjust(screen_device::DEFAULT_FRAME_PERIOD, 0, screen_device::DEFAULT_FRAME_PERIOD); machine.output().set_notifier(nullptr, video_notifier_callback, this); } }
static void dump_screenshot(running_machine &machine, int write_file) { file_error filerr; char buf[128]; int is_blank = 0; if (write_file) { /* dump a screenshot */ snprintf(buf, ARRAY_LENGTH(buf), (screenshot_num >= 0) ? "_%s_%d.png" : "_%s.png", current_testcase.name, screenshot_num); emu_file fp(machine.options(), SEARCHPATH_SCREENSHOT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE); filerr = fp.open(buf); if (filerr == FILERR_NONE) { /* choose a screen */ screen_device *screen = machine.first_screen(); while((screen != NULL) && !machine.render().is_live(*screen)) { screen = screen->next_screen(); } /* did we find a live screen? */ if (screen != NULL) { screen->machine().video().save_snapshot(screen, fp); report_message(MSG_INFO, "Saved screenshot as %s", buf); } else { report_message(MSG_FAILURE, "Could not save screenshot; no live screen"); } } else { /* report the error */ report_message(MSG_FAILURE, "Could not save screenshot; error #%d", filerr); } if (screenshot_num >= 0) screenshot_num++; } #if 0 /* check to see if bitmap is blank */ bitmap = scrbitmap[0]; is_blank = 1; color = bitmap->read(bitmap, 0, 0); for (y = 0; is_blank && (y < bitmap->height); y++) { for (x = 0; is_blank && (x < bitmap->width); x++) { if (bitmap->read(bitmap, x, y) != color) is_blank = 0; } } #endif if (is_blank) { had_failure = TRUE; report_message(MSG_FAILURE, "Screenshot is blank"); } }