예제 #1
0
        string m_string_buffer;  //mutable util::ovectorstream m_string_buffer;


        // construction/destruction

        //-------------------------------------------------
        //  running_machine - constructor
        //-------------------------------------------------
        public running_machine(machine_config _config, machine_manager manager)
        {
            m_side_effects_disabled = 0;
            debug_flags             = 0;
            m_config                 = _config;
            m_system                 = _config.gamedrv();
            m_manager                = manager;
            m_current_phase          = machine_phase.PREINIT;
            m_paused                 = false;
            m_hard_reset_pending     = false;
            m_exit_pending           = false;
            m_soft_reset_timer       = null;
            m_rand_seed              = 0x9d14abd7;
            m_ui_active              = _config.options().ui_active();
            m_basename               = _config.gamedrv().name;
            m_sample_rate            = _config.options().sample_rate();
            m_saveload_schedule      = saveload_schedule.NONE;
            m_saveload_schedule_time = attotime.zero;
            m_saveload_searchpath    = null;

            m_save      = new save_manager(this);
            m_memory    = new memory_manager(this);
            m_ioport    = new ioport_manager(this);
            m_scheduler = new device_scheduler(this);
            m_scheduler.device_scheduler_after_ctor(this);


            for (int i = 0; i < m_notifier_list.Length; i++)
            {
                m_notifier_list[i] = new std.list <notifier_callback_item>();
            }

            m_base_time = 0;

            // set the machine on all devices
            device_enumerator iter = new device_enumerator(root_device());

            foreach (device_t device in iter)
            {
                device.set_machine(this);
            }

            // fetch core options
            if (options().debug())
            {
                debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (DEBUG_FLAG_OSD_ENABLED);
            }
        }
예제 #2
0
        //-------------------------------------------------
        //  interface_pre_start - work to be done prior to
        //  actually starting a device
        //-------------------------------------------------
        public override void interface_pre_start()
        {
            m_scheduler = device().machine().scheduler();

            // bind delegates
            //m_vblank_interrupt.resolve();
            //m_timed_interrupt.resolve();
            //m_driver_irq.resolve();

            // fill in the initial states
            int index = new device_enumerator(device().machine().root_device()).indexof(device());

            m_suspend    = SUSPEND_REASON_RESET;
            m_profiler   = (profile_type)(index + profile_type.PROFILER_DEVICE_FIRST);
            m_inttrigger = index + TRIGGER_INT;

            // allocate timers if we need them
            if (m_timed_interrupt_period != attotime.zero)
            {
                m_timedint_timer = m_scheduler.timer_alloc(trigger_periodic_interrupt, this);
            }
        }
예제 #3
0
        //-------------------------------------------------
        //  update_text - update the current astring
        //-------------------------------------------------
        void update_text(running_machine machine)
        {
            // compute the total time for all bits, not including profiler or idle
            u64          computed = 0;
            profile_type curtype;

            for (curtype = profile_type.PROFILER_DEVICE_FIRST; curtype < profile_type.PROFILER_PROFILER; curtype++)
            {
                computed += m_data[(int)curtype];
            }

            // save that result in normalize, and continue adding the rest
            u64 normalize = computed;

            for ( ; curtype < profile_type.PROFILER_TOTAL; curtype++)
            {
                computed += m_data[(int)curtype];
            }

            // this becomes the total; if we end up with 0 for anything, we were just started, so return empty
            u64 total = computed;

            if (total == 0 || normalize == 0)
            {
                m_text = "";
                return;
            }

            // loop over all types and generate the string
            device_enumerator iter   = new device_enumerator(machine.root_device());
            string            stream = "";

            for (curtype = profile_type.PROFILER_DEVICE_FIRST; curtype < profile_type.PROFILER_TOTAL; curtype++)
            {
                // determine the accumulated time for this type
                computed = m_data[(int)curtype];

                // if we have non-zero data and we're ready to display, do it
                if (computed != 0)
                {
                    // start with the un-normalized percentage
                    util.stream_format(ref stream, "{0}%% ", (int)((computed * 100 + total / 2) / total));

                    // followed by the normalized percentage for everything but profiler and idle
                    if (curtype < profile_type.PROFILER_PROFILER)
                    {
                        util.stream_format(ref stream, "{0}%% ", (int)((computed * 100 + normalize / 2) / normalize));
                    }

                    // and then the text
                    if (curtype >= profile_type.PROFILER_DEVICE_FIRST && curtype <= profile_type.PROFILER_DEVICE_MAX)
                    {
                        util.stream_format(ref stream, "'{0}'", iter.byindex(curtype - profile_type.PROFILER_DEVICE_FIRST).tag());
                    }
                    else
                    {
                        for (int nameindex = 0; nameindex < names.Length; nameindex++)
                        {
                            if (names[nameindex].type == (int)curtype)
                            {
                                stream += names[nameindex].str;
                                break;
                            }
                        }
                    }

                    // followed by a carriage return
                    stream += "\n";
                }
            }

            // reset data set to 0
            std.memset <osd_ticks_t>(m_data, 0, (size_t)m_data.Length);
            m_text = stream;
        }