// allocation and re-use //------------------------------------------------- // init - completely initialize the state when // re-allocated as a non-device timer //------------------------------------------------- public emu_timer init(running_machine machine, timer_expired_delegate callback, object o, bool temporary) { // ensure the entire timer state is clean m_machine = machine; m_next = null; m_prev = null; m_callback = callback; m_param = 0; m_ptr = o; m_enabled = false; m_temporary = temporary; m_period = attotime.never; m_start = machine.time(); m_expire = attotime.never; m_device = null; m_id = 0; // if we're not temporary, register ourselves with the save state system if (!m_temporary) { register_save(); } // insert into the list machine.scheduler().timer_list_insert(this); return(this); }
public override void ui_initialize(running_machine machine) { m_ui.initialize(machine); // display the startup screens m_ui.display_startup_screens(m_firstrun); }
//------------------------------------------------- // init - completely initialize the state when // re-allocated as a device timer //------------------------------------------------- public emu_timer init(device_t device, device_timer_id id, object ptr, bool temporary) { // ensure the entire timer state is clean m_machine = device.machine(); m_next = null; m_prev = null; m_callback = null; m_param = 0; m_ptr = ptr; m_enabled = false; m_temporary = temporary; m_period = attotime.never; m_start = machine().time(); m_expire = attotime.never; m_device = device; m_id = id; // if we're not temporary, register ourselves with the save state system if (!m_temporary) { register_save(); } // insert into the list machine().scheduler().timer_list_insert(this); return(this); }
/*------------------------------------------------- * frame_update - looks through pressed * input as per events pushed our way and posts * corresponding IPT_UI_* events * -------------------------------------------------*/ void frame_update(running_machine machine) { /* update the state of all the UI keys */ for (ioport_type code = (ioport_type)(ioport_type.IPT_UI_FIRST + 1); code < ioport_type.IPT_UI_LAST; ++code) { bool pressed = machine.ioport().type_pressed(code); if (!pressed || m_seqpressed[(int)code] != SEQ_PRESSED_RESET) { m_seqpressed[(int)code] = pressed ? (byte)1 : (byte)0; } } // perform mouse hit testing ioport_field mouse_field = m_current_mouse_down ? find_mouse_field() : null; if (m_current_mouse_field != mouse_field) { // clear the old field if there was one if (m_current_mouse_field != null) { m_current_mouse_field.set_value(0); } // set the new field if it exists and isn't already being pressed if (mouse_field != null && !mouse_field.digital_value()) { mouse_field.set_value(1); } // update internal state m_current_mouse_field = mouse_field; } }
running_machine m_machine; // reference to our machine //std::unique_ptr<debugger_commands> m_commands; //std::unique_ptr<debugger_cpu> m_cpu; //std::unique_ptr<debugger_console> m_console; // construction/destruction //------------------------------------------------- // debugger_manager - constructor //------------------------------------------------- public debugger_manager(running_machine machine) { m_machine = machine; //throw new emu_unimplemented(); #if false /* initialize the submodules */ m_cpu = std::make_unique <debugger_cpu>(machine); m_console = std::make_unique <debugger_console>(machine); m_commands = std::make_unique <debugger_commands>(machine, cpu(), console()); g_machine = &machine; /* register an atexit handler if we haven't yet */ if (!g_atexit_registered) { atexit(debugger_flush_all_traces_on_abnormal_exit); } g_atexit_registered = TRUE; /* initialize osd debugger features */ machine.osd().init_debugger(); #endif }
public override void before_load_settings(running_machine machine) { //throw new emu_unimplemented(); #if false m_lua.on_machine_before_load_settings(); #endif }
running_machine m_machine; // reference to our machine // construction/destruction //------------------------------------------------- // network_manager - constructor //------------------------------------------------- public network_manager(running_machine machine) { m_machine = machine; machine.configuration().config_register("network", config_load, config_save); }
keycode_map m_keycode_map = new keycode_map(); // keycode map // construction/destruction //------------------------------------------------- // natural_keyboard - constructor //------------------------------------------------- public natural_keyboard(running_machine machine) { m_machine = machine; m_in_use = false; m_bufbegin = 0; m_bufend = 0; m_fieldnum = 0; m_status_keydown = false; m_last_cr = false; m_timer = null; m_current_rate = attotime.zero; m_queue_chars = null; m_accept_char = null; m_charqueue_empty = null; // try building a list of keycodes; if none are available, don't bother build_codes(machine.ioport()); if (!m_keycode_map.empty()) { m_buffer.resize(KEY_BUFFER_SIZE); m_timer = machine.scheduler().timer_alloc(timer); } // retrieve option setting set_in_use(machine.options().natural_keyboard()); }
bool m_disabled; // true if the cheat engine is disabled //symbol_table m_symtable; // global symbol table // construction/destruction //------------------------------------------------- // cheat_manager - constructor //------------------------------------------------- public cheat_manager(running_machine machine) { m_disabled = true; //throw new emu_unimplemented(); #if false #endif }
//------------------------------------------------- // reset - reset all sound chips //------------------------------------------------- void reset(running_machine machine) { // reset all the sound chips foreach (device_sound_interface sound in new sound_interface_iterator(machine.root_device())) { sound.device().reset(); } }
//------------------------------------------------- // stop_recording - end audio recording //------------------------------------------------- void stop_recording(running_machine machine) { // close any open WAV file if (m_wavfile != null) { wavwrite_global.wav_close(m_wavfile); } m_wavfile = null; }
// return true if any crosshairs are used //bool get_usage() const { return m_usage; } // getters //running_machine &machine() const { return m_machine; } //render_crosshair &get_crosshair(int player) const { assert(player >= 0 && player < MAX_PLAYERS); assert(m_crosshair[player] != nullptr); return *m_crosshair[player]; } //u16 auto_time() const { return m_auto_time; } //void set_auto_time(u16 auto_time) { m_auto_time = auto_time; } /*------------------------------------------------- * exit - free memory allocated for * the crosshairs * -------------------------------------------------*/ void exit(running_machine machine_) { /* free bitmaps and textures for each player */ for (int player = 0; player < MAX_PLAYERS; player++) { m_crosshair[player].Dispose(); m_crosshair[player] = null; } }
public void device_scheduler_after_ctor(running_machine machine) { // ED: there's a circular dependency with device_scheduler. it creates a emu_timer, which calls machine.time(). so we null check here to fix that. // append a single never-expiring timer so there is always one in the list m_timer_list = m_timer_allocator.alloc().init(machine, null, null, true); m_timer_list.adjust(attotime.never); }
// construction/destruction //------------------------------------------------- // output_manager - constructor //------------------------------------------------- public output_manager(running_machine machine) { m_machine = machine; m_uniqueid = 12345; /* add pause callback */ machine.add_notifier(machine_notification.MACHINE_NOTIFY_PAUSE, pause); machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESUME, resume); }
// internal helpers //------------------------------------------------- // frame_callback - per-frame callback for various // bookkeeping //------------------------------------------------- void frame_callback(running_machine machine) { // iterate over all devices in our class for (int devnum = 0; devnum <= maxindex(); devnum++) { if (device(devnum) != null) { ((input_device_keyboard)device(devnum)).apply_steadykey(); } } }
public override ui_manager create_ui(running_machine machine) { m_ui = new mame_ui_manager(machine); m_ui.init(); machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESET, reset); m_ui.set_startup_text("Initializing...", true); return(m_ui); }
//------------------------------------------------- // unload_all - unload all images and // extract options //------------------------------------------------- void unload_all(running_machine machine) { // extract the options options_extract(); foreach (device_image_interface image in new image_interface_iterator(machine.root_device())) { // unload this image image.unload(); } }
public override void create_custom(running_machine machine) { // start the inifile manager m_inifile = new inifile_manager(m_ui.options()); // allocate autoboot timer m_autoboot_timer = machine.scheduler().timer_alloc(autoboot_callback); // start favorite manager m_favorite = new favorite_manager(m_ui.options()); }
// construction/destruction /*------------------------------------------------- * output_manager - constructor * -------------------------------------------------*/ public output_manager(running_machine machine) { m_machine = machine; m_uniqueid = 12345; // add callbacks machine.add_notifier(machine_notification.MACHINE_NOTIFY_PAUSE, pause); machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESUME, resume); machine.save().register_presave(presave); //machine.save().register_presave(save_prepost_delegate(FUNC(output_manager::presave), this)); machine.save().register_postload(postload); //machine.save().register_postload(save_prepost_delegate(FUNC(output_manager::postload), this)); }
u16 m_auto_time; // time in seconds to turn invisible // construction/destruction //------------------------------------------------- // crosshair_manager - constructor //------------------------------------------------- public 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_notification.MACHINE_NOTIFY_EXIT, exit); for (int player = 0; player < MAX_PLAYERS; player++) { m_crosshair[player] = new render_crosshair(machine, player); } /* determine who needs crosshairs */ foreach (var port in machine.ioport().ports()) { foreach (ioport_field field in port.Value.fields()) { if (field.crosshair_axis() != crosshair_axis_t.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_load, config_save); } /* register the animation callback */ screen_device first_screen = new screen_device_enumerator(machine.root_device()).first(); if (first_screen != null) { first_screen.register_vblank_callback(animate); } }
public static void display_ui_chooser(running_machine machine) { mame_ui_manager mui = mame_machine_manager.instance().ui(); render_container container = machine.render().ui_container(); if (machine.options().ui() == emu_options.ui_option.UI_SIMPLE) { ui.simple_menu_select_game.force_game_select(mui, container); } else { ui.menu_select_game.force_game_select(mui, container); } }
attotime m_last_update; // last update time // construction/destruction //------------------------------------------------- // sound_manager - constructor //------------------------------------------------- public sound_manager(running_machine machine) { m_machine = machine; m_update_timer = null; m_finalmix_leftover = 0; m_finalmix = new std.vector <s16>(machine.sample_rate()); m_leftmix = new std.vector <s32>(machine.sample_rate()); m_rightmix = new std.vector <s32>(machine.sample_rate()); m_nosound_mode = machine.osd().no_sound() ? 1 : 0; m_wavfile = null; m_update_attoseconds = STREAMS_UPDATE_ATTOTIME.attoseconds(); m_last_update = attotime.zero; // get filename for WAV file or AVI file if specified string wavfile = machine.options().wav_write(); string avifile = machine.options().avi_write(); // handle -nosound and lower sample rate if not recording WAV or AVI if (m_nosound_mode != 0 && string.IsNullOrEmpty(wavfile) && string.IsNullOrEmpty(avifile)) { machine.sample_rate_set(11025); } // count the mixers if (sound_global.VERBOSE) { mixer_interface_iterator iter = new mixer_interface_iterator(machine.root_device()); sound_global.VPRINTF("total mixers = {0}\n", iter.count()); } // register callbacks machine.configuration().config_register("mixer", config_load, config_save); machine.add_notifier(machine_notification.MACHINE_NOTIFY_PAUSE, pause); machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESUME, resume); machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESET, reset); machine.add_notifier(machine_notification.MACHINE_NOTIFY_EXIT, stop_recording); // register global states machine.save().save_item(m_last_update, "m_last_update"); // set the starting attenuation set_attenuation(machine.options().volume()); // start the periodic update flushing timer m_update_timer = machine.scheduler().timer_alloc(update, this); m_update_timer.adjust(STREAMS_UPDATE_ATTOTIME, 0, STREAMS_UPDATE_ATTOTIME); }
//------------------------------------------------- // text - return the current text in an astring //------------------------------------------------- public string text(running_machine machine) { start(profile_type.PROFILER_PROFILER); // get the current time attotime current_time = machine.scheduler().time(); // we only want to update the text periodically if ((m_text_time == attotime.never) || ((current_time - m_text_time).as_double() >= TEXT_UPDATE_TIME)) { update_text(machine); m_text_time = current_time; } stop(); return(m_text); }
attoseconds_t m_quantum_minimum; // duration of minimum quantum // construction/destruction //------------------------------------------------- // device_scheduler - constructor //------------------------------------------------- public device_scheduler(running_machine machine) { m_machine = machine; m_basetime = attotime.zero; m_callback_timer_expire_time = attotime.zero; m_suspend_changes_pending = true; m_quantum_minimum = ATTOSECONDS_IN_NSEC(1) / 1000; // append a single never-expiring timer so there is always one in the list //m_timer_list = m_timer_allocator.alloc().init(machine, null, null, true); //m_timer_list.adjust(attotime.never); // register global states machine.save().save_item(m_basetime, "m_basetime"); machine.save().register_presave(presave); machine.save().register_postload(postload); }
// construction/destruction //------------------------------------------------- // ui_input_manager - constructor //------------------------------------------------- public ui_input_manager(running_machine machine) { m_machine = machine; m_current_mouse_target = null; m_current_mouse_down = false; m_current_mouse_field = null; m_events_start = 0; m_events_end = 0; /* create the private data */ m_current_mouse_x = -1; m_current_mouse_y = -1; /* add a frame callback to poll inputs */ machine.add_notifier(machine_notification.MACHINE_NOTIFY_FRAME, frame_update); }
string m_name = ""; // name of png file // construction/destruction //------------------------------------------------- // render_crosshair - constructor //------------------------------------------------- public 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 = null; 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 = new screen_device_enumerator(machine.root_device()).first(); }
// internal helpers //------------------------------------------------- // video_exit - close down the video system //------------------------------------------------- void exit(running_machine machine_) { // stop recording any movie m_movie_recordings.clear(); // free the snapshot target machine().render().target_free(m_snap_target); m_snap_bitmap.reset(); // print a final result if we have at least 2 seconds' worth of data if (!emulator_info.standalone() && m_overall_emutime.seconds() >= 1) { osd_ticks_t tps = m_osdcore.osd_ticks_per_second(); double final_real_time = (double)m_overall_real_seconds + (double)m_overall_real_ticks / (double)tps; double final_emu_time = m_overall_emutime.as_double(); osd_printf_info("Average speed: {0}%% ({1} seconds)\n", 100 * final_emu_time / final_real_time, (m_overall_emutime + new attotime(0, ATTOSECONDS_PER_SECOND / 2)).seconds()); // %.2f%% (%d seconds)\n } }
running_machine m_machine; // reference to our machine // construction/destruction public image_manager(running_machine machine) { m_machine = machine; // make sure that any required devices have been allocated foreach (device_image_interface image in new image_interface_iterator(machine.root_device())) { // ignore things not user loadable if (!image.user_loadable()) { continue; } throw new emu_unimplemented(); } machine.configuration().config_register("image_directories", config_load, config_save); }
// construction/destruction //------------------------------------------------- // ui_input_manager - constructor //------------------------------------------------- public ui_input_manager(running_machine machine) { m_machine = machine; m_presses_enabled = true; m_current_mouse_target = null; m_current_mouse_x = -1; m_current_mouse_y = -1; m_current_mouse_down = false; m_current_mouse_field = null; m_events_start = 0; m_events_end = 0; std.fill(m_next_repeat, (osd_ticks_t)0); std.fill(m_seqpressed, (u8)0); // add a frame callback to poll inputs machine.add_notifier(machine_notification.MACHINE_NOTIFY_FRAME, frame_update); }
// construction/destruction //------------------------------------------------- // bookkeeping_manager - constructor //------------------------------------------------- public bookkeeping_manager(running_machine machine) { m_machine = machine; m_dispensed_tickets = 0; /* reset coin counters */ for (int counternum = 0; counternum < COIN_COUNTERS; counternum++) { m_lastcoin[counternum] = 0; m_coinlockedout[counternum] = 0; m_coin_count[counternum] = 0; } // register coin save state machine.save().save_item(m_coin_count, "m_coin_count"); machine.save().save_item(m_coinlockedout, "m_coinlockedout"); machine.save().save_item(m_lastcoin, "m_lastcoin"); machine.save().save_item(m_dispensed_tickets, "m_dispensed_tickets"); // register for configuration machine.configuration().config_register("counters", config_load, config_save); }